Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Proper handling of unhandledRejection event #262

Closed
LewisJEllis opened this issue Jan 26, 2017 · 1 comment
Closed

Proper handling of unhandledRejection event #262

LewisJEllis opened this issue Jan 26, 2017 · 1 comment

Comments

@LewisJEllis
Copy link
Contributor

We have a config option captureUnhandledRejections which is off by default but can be enabled to have Raven capture unhandled rejections automatically.

Here's what we do now:

  • Capture the rejection
  • Invoke the install callback which by default will exit the process

In the absence of Raven, unhandled rejections do not currently result in the process exiting, but enabling our captureUnhandledRejections option changes that.

In relation to discussion in #257 we determined that what we should do instead is:

  • continue doing nothing with unhandledRejections by default
  • keep the captureUnhandledRejections flag which adds a process.on('unhandledRejection') handler but does not result in calling install()'s onFatalError callback

This is a behavior change, but a good and necessary one. The key that really convinced me of the necessity of this change was that basically there are edge cases where an unhandledRejection event can be emitted but the rejection can later be handled by user application code. We don't want to incorrectly exit prematurely in that case, and this is also in line with our desire to have the exit conditions of a program not change when adding or removing Raven.

Note that unhandled rejections do result in a warning starting with Node 7, and in the future a garbage-collected unhandled rejection will result in the process exiting (see nodejs/node#6375), and this decision should make it easy for us to fall in line with that change when it happens.

@LewisJEllis
Copy link
Contributor Author

Updated this behavior in #308; will update again whenever node's default behavior changes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant