ChainSafe / discv5

A Typescript implementation of the Discv5 protocol
Apache License 2.0
28 stars 15 forks source link

`UnhandledPromiseRejection` in `sendPing` #265

Open acolytec3 opened 11 months ago

acolytec3 commented 11 months ago

We've recently started noticing some unhandled promise rejections that are being thrown by discv5.sendPing inside of Ultralight. The stack trace for the error looks like below:

    at callback (file:///home/jim/development/ultralight/node_modules/@chainsafe/discv5/lib/service/service.js:354:33)
    at SessionService.rpcFailure (file:///home/jim/development/ultralight/node_modules/@chainsafe/discv5/lib/service/service.js:811:13)
    at SessionService.emit (node:events:514:28)
    at SessionService.failRequest (file:///home/jim/development/ultralight/node_modules/@chainsafe/discv5/lib/session/service.js:650:14)
    at SessionService.handleRequestTimeout (file:///home/jim/development/ultralight/node_modules/@chainsafe/discv5/lib/session/service.js:615:18)
    at TimeoutMap.onTimeout (file:///home/jim/development/ultralight/node_modules/@chainsafe/discv5/lib/session/service.js:98:84)
    at Timeout.<anonymous> (file:///home/jim/development/ultralight/node_modules/@chainsafe/discv5/lib/util/timeoutMap.js:25:22)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

and the debugger links the source of the error to this promise rejection in sendPing.

I looked through the calls to sendPing in the discv5 codebase and it doesn't look like any of them are directly wrapped in try/catch blocks so not sure where I need to look to see why this isn't being handled since it looks like it's a basic session timeout issue (which shouldn't be a critical requiring a consuming application to handle it.

Since we never call discv5.sendPing directly inside Ultralight, I'm trying to determine if this is some new issue that has cropped up with discv5 or if it's something Ultralight did (or didn't) do with regard to properly guarding network calls with our discv5 client.

Any suggestions?

For our part, we're temporarily employing a process.on('uncaughtException... handler to keep Ultralight from crashing for now since as best I can tell this comes from trying to ping unreachable nodes and the rejections just not being handled properly.