interledger / rafiki

An open-source, comprehensive Interledger service for wallet providers, enabling them to provide Interledger functionality to their users.
https://rafiki.dev/
Apache License 2.0
262 stars 88 forks source link

Fix packet expiry error handling #3075

Open mkurapov opened 2 weeks ago

mkurapov commented 2 weeks ago

Bug Report

Currently, when the sending ILP connector sends a packet and it expires, we end up crashing the node process. This is because the packet expiry check is done via setTimeout, with the callback throwing an error that causes an uncaughtException. This leads to a SIGTERM, and the app crashes/exits.

https://github.com/interledger/rafiki/blob/cd3d89373e4f24fddbd1da5347e4ec7e44d8b61e/packages/backend/src/payment-method/ilp/connector/core/middleware/expire.ts#L10-L26

Expected behavior

The node process does not crash/exit if a packet from the sending connector expires.

Additional context

setTimeout callbacks are treated in a separate call stack as part of the node event loop, this means they are handled outside of the code where they were registered.