Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node): prevent node crash on uncaught exception #1001

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mothershipper
Copy link

@mothershipper mothershipper commented May 30, 2024

🚥 Resolves #876

🧰 Changes

When fire-and-forget is set, the request promise isn't returned to the log handler, meaning the catch here doesn't prevent node from exiting on a request failure.

We also got caught with a trio of bugs:

  1. Fire-And-Forget is not passed through the SDK, so this commit on its own does not solve the issue (fixed by fix(node): fireAndForget was not respected #1002)
  2. When development is set to true another floating promise rejects and crashes the process ("fixed" by fix(node): avoid rethrowing errors when development=true #1003 but likely requires follow-up)
  3. ^when fire-and-forget is set (and passed through) this uncaught rejection crashes the process. (fixed by this PR)

Apologies on the order of discovery here, was debugging with my eyes rather than a debugger.

Fixing issue 2 (development rethrows) is probably not something I can contribute outside of just removing the re-throw behavior. Not sure how you want to handle error handling within your SDK (logging, letting the caller supply a handler, etc.).

🧬 QA & Testing

Send a large load of traffic at a node service, watch it crash. To be honest, haven't tested this patch yet, working on confirming this fixes it, but I'm like 99% sure this does the trick.

@erunion erunion requested review from azinder1 and a team May 30, 2024 22:14
@erunion erunion added bug Something isn't working area:node labels May 30, 2024
When fire-and-forget is set, the request promise isn't returned to the log
handler, meaning the [catch here](https://github.com/readmeio/metrics-sdks/blob/main/packages/node/src/lib/log.ts#L28-L31)
doesn't prevent node from exiting on a request failure.
@mothershipper mothershipper changed the title Fix node crash on uncaught exception fix(node): prevent node crash on uncaught exception May 30, 2024
@erunion erunion added node Issues related to our Node SDK and removed area:node labels Jul 26, 2024
@gratcliff gratcliff removed the request for review from a team November 15, 2024 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node Issues related to our Node SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nodejs Abort error
2 participants