mirror of https://github.com/waku-org/nwaku.git
fix: wrap untracked protocol handler exceptions
This commit is contained in:
parent
418efca27f
commit
9e1432c9ef
|
@ -57,7 +57,15 @@ proc initProtocolHandler*(wl: WakuLightPush) =
|
||||||
debug "push request", peerId=conn.peerId, requestId=req.requestId, pubsubTopic=pubsubTopic
|
debug "push request", peerId=conn.peerId, requestId=req.requestId, pubsubTopic=pubsubTopic
|
||||||
|
|
||||||
var response: PushResponse
|
var response: PushResponse
|
||||||
let handleRes = await wl.pushHandler(conn.peerId, pubsubTopic, message)
|
var handleRes: WakuLightPushResult[void]
|
||||||
|
try:
|
||||||
|
handleRes = await wl.pushHandler(conn.peerId, pubsubTopic, message)
|
||||||
|
except Exception:
|
||||||
|
response = PushResponse(is_success: false, info: some(getCurrentExceptionMsg()))
|
||||||
|
waku_lightpush_errors.inc(labelValues = [messagePushFailure])
|
||||||
|
error "pushed message handling failed", error= getCurrentExceptionMsg()
|
||||||
|
|
||||||
|
|
||||||
if handleRes.isOk():
|
if handleRes.isOk():
|
||||||
response = PushResponse(is_success: true, info: some("OK"))
|
response = PushResponse(is_success: true, info: some("OK"))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -72,7 +72,17 @@ proc initProtocolHandler(ws: WakuStore) =
|
||||||
info "received history query", peerId=conn.peerId, requestId=requestId, query=request
|
info "received history query", peerId=conn.peerId, requestId=requestId, query=request
|
||||||
waku_store_queries.inc()
|
waku_store_queries.inc()
|
||||||
|
|
||||||
let responseRes = ws.queryHandler(request)
|
var responseRes: HistoryResult
|
||||||
|
try:
|
||||||
|
responseRes = ws.queryHandler(request)
|
||||||
|
except Exception:
|
||||||
|
error "history query failed", peerId= $conn.peerId, requestId=requestId, error=getCurrentExceptionMsg()
|
||||||
|
|
||||||
|
let error = HistoryError(kind: HistoryErrorKind.UNKNOWN).toRPC()
|
||||||
|
let response = HistoryResponseRPC(error: error)
|
||||||
|
let rpc = HistoryRPC(requestId: requestId, response: some(response))
|
||||||
|
await conn.writeLp(rpc.encode().buffer)
|
||||||
|
return
|
||||||
|
|
||||||
if responseRes.isErr():
|
if responseRes.isErr():
|
||||||
error "history query failed", peerId= $conn.peerId, requestId=requestId, error=responseRes.error
|
error "history query failed", peerId= $conn.peerId, requestId=requestId, error=responseRes.error
|
||||||
|
|
Loading…
Reference in New Issue