fix: exit server after reconfiguring - #1102
Open
alecgibson wants to merge 1 commit into
Open
Conversation
alecgibson
force-pushed
the
fix-exit-after-reconfigure
branch
from
April 20, 2023 10:04
6216702 to
fe33658
Compare
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
force-pushed
the
fix-exit-after-reconfigure
branch
from
September 29, 2023 08:25
fe33658 to
2e1fe81
Compare
Author
|
@waltjones any chance of please getting this reviewed? We've still got an ugly patch in our code to work around this issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the change
According to the docs,
exitOnUncaughtExceptionshould:So with this config:
...an uncaught exception should exit the process.
This works correctly, but only if
rollbar.configure()is never called again, because:exitOnUncaughtExceptionwas deleted from our optionsconfigure()callssetupUnhandledCapture()...handleUncaughtExceptions()...options.exitOnUncaughtExceptionuncaughtExceptionhandler, we now haveexitOnUncaught = falseThis change:
exitOnUncaughtExceptionfrom options (it's unclear why this is the only option that is deleted)options.exitOnUncaughtExceptionin the handler, just likeoptions.captureUncaughtis accessed directlyType of change
Development
Code review