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: exit server after reconfiguring #1102

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

Conversation

alecgibson
Copy link

@alecgibson alecgibson commented Apr 20, 2023

Description of the change

According to the docs, exitOnUncaughtException should:

Exit the process after handling an uncaught exception. Requires
captureUncaught to also be set.

So with this config:

var rollbar = new Rollbar({
  captureUncaught: true,
  exitOnUncaughtException: true,
  // ...
});

...an uncaught exception should exit the process.

This works correctly, but only if rollbar.configure() is never called again, because:

  1. exitOnUncaughtException was deleted from our options
  2. Calling configure() calls setupUnhandledCapture()...
  3. ...which calls handleUncaughtExceptions()...
  4. ...which now tries to access options.exitOnUncaughtException
  5. But this option was deleted in Step 1, so when we replace our uncaughtException handler, we now have exitOnUncaught = false

This change:

  • no longer deletes exitOnUncaughtException from options (it's unclear why this is the only option that is deleted)
  • directly accesses options.exitOnUncaughtException in the handler, just like options.captureUncaught is accessed directly

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

@alecgibson alecgibson force-pushed the fix-exit-after-reconfigure branch from 6216702 to fe33658 Compare April 20, 2023 10:04
According to [the docs][1], `exitOnUncaughtException` should:

> Exit the process after handling an uncaught exception. Requires
> `captureUncaught` to also be set.

So with this config:

```js
var rollbar = new Rollbar({
  captureUncaught: true,
  exitOnUncaughtException: true,
  // ...
});
```

...an uncaught exception should exit the process.

This works correctly, but *only* if `rollbar.configure()` is *never*
called again, because:

 1. `exitOnUncaughtException` [was deleted][2] from our options
 2. Calling `configure()` calls [`setupUnhandledCapture()`][3]...
 3. ...which calls [`handleUncaughtExceptions()`][4]...
 4. ...which now [tries to access][5] `options.exitOnUncaughtException`
 5. But this option was deleted in Step 1, so when we [replace][6] our
    `uncaughtException` handler, we now have `exitOnUncaught = false`

This change:

 - no longer deletes `exitOnUncaughtException` from options (it's
   unclear why this is the only option that is deleted)
 - directly accesses `options.exitOnUncaughtException` in the
   handler, just like `options.captureUncaught` is accessed directly

[1]: https://docs.rollbar.com/docs/rollbarjs-configuration-reference#context-1
[2]: https://github.com/rollbar/rollbar.js/blob/e964ecbdb16a4d2b8b5feaa8b70a2ec327648ed0/src/server/rollbar.js#L587
[3]: https://github.com/rollbar/rollbar.js/blob/e964ecbdb16a4d2b8b5feaa8b70a2ec327648ed0/src/server/rollbar.js#L118
[4]: https://github.com/rollbar/rollbar.js/blob/e964ecbdb16a4d2b8b5feaa8b70a2ec327648ed0/src/server/rollbar.js#L578
[5]: https://github.com/rollbar/rollbar.js/blob/e964ecbdb16a4d2b8b5feaa8b70a2ec327648ed0/src/server/rollbar.js#L586
[6]: https://github.com/rollbar/rollbar.js/blob/e964ecbdb16a4d2b8b5feaa8b70a2ec327648ed0/src/server/rollbar.js#L589
@alecgibson alecgibson force-pushed the fix-exit-after-reconfigure branch from fe33658 to 2e1fe81 Compare September 29, 2023 08:25
@alecgibson
Copy link
Author

@waltjones any chance of please getting this reviewed? We've still got an ugly patch in our code to work around this issue.

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

Successfully merging this pull request may close these issues.

1 participant