-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(node): Add option to OnUncaughtException
integration that allows mimicking native uncaught error exit behaviour
#6137
feat(node): Add option to OnUncaughtException
integration that allows mimicking native uncaught error exit behaviour
#6137
Conversation
…ws mimicing native exit behaviour
|
||
const testScriptPath = path.resolve(__dirname, 'no-additional-listener-test-script.js'); | ||
|
||
childProcess.exec(`node ${testScriptPath}`, { encoding: 'utf8' }, (err, stdout) => { |
Check warning
Code scanning / CodeQL
Shell command built from environment values
|
||
const testScriptPath = path.resolve(__dirname, 'additional-listener-test-script.js'); | ||
|
||
childProcess.exec(`node ${testScriptPath}`, { encoding: 'utf8' }, (err, stdout) => { |
Check warning
Code scanning / CodeQL
Shell command built from environment values
|
||
const testScriptPath = path.resolve(__dirname, 'mimic-behaviour-no-additional-listener-test-script.js'); | ||
|
||
childProcess.exec(`node ${testScriptPath}`, { encoding: 'utf8' }, (err, stdout) => { |
Check warning
Code scanning / CodeQL
Shell command built from environment values
|
||
const testScriptPath = path.resolve(__dirname, 'mimic-behaviour-additional-listener-test-script.js'); | ||
|
||
childProcess.exec(`node ${testScriptPath}`, { encoding: 'utf8' }, (err, stdout) => { |
Check warning
Code scanning / CodeQL
Shell command built from environment values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - as previously discussed offline, the option name and some of the uncaught exception code is generally not ideal, but we can/should revisit this for v8 or similar. Great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work man! I have some logaf-l suggestions but we can revisit them ofc also later
...tes/public-api/OnUncaughtException/mimic-native-behaviour-additional-listener-test-script.js
Show resolved
Hide resolved
OnUncaughtException
integration that allows mimicking native exit behaviourOnUncaughtException
integration that allows mimicking native uncaught error exit behaviour
I have a little question about this one: If I understand correctly We migrated from 6.* to 7.18 and we suddenly had a lot of pods killed because of it. Is there an easy way to remove that behavior? I saw that we can do :
Isn't it dangerous to bypass the default behavior and call Thank you :) |
Hey @Nikoms
Yes you are correct. As per the Node docs if an unhandled rejection is triggered the process should be exited: https://nodejs.org/api/process.html#warning-using-uncaughtexception-correctly. In this case, the default behavior is to exit the process, and if you register a custom handler, you should also be exiting the process. Since Sentry is registering a custom handler, we are exiting the process as a result.
We added this option to allow users to override this behaviour, although we don't recommend it since it's not recommended by the Node standard library itself. |
Hey @AbhiPrasad, thank you for your explanation. Sorry if I'm challenging this a bit 😁 I think it would be fair to say in red somewhere "sentry can exit the process for you by default". Or disabling this feature by default, because it sounds like a BC break but was added in a minor if I'm not wrong. I'm 100 % agree that we should all follow the recommendation of node. In that case, we can safely imagine that if there is another handler, it will exit the process, so sentry doesn't have to (talking about |
Ok i just found that it's because of the "7.12.0" release, not this because of this commit :/ Sorry. Previously my "uncaughtException" was never called, not it is. |
This PR introduces an option (
exitEvenWhenOtherOnUncaughtExceptionHandlersAreRegistered
) that allows users to to mimic the native node exit behaviour on errors, in the way that the integration won't exit by itself when there are additionalOnUncaughtException
handlers registered.Original implementation: #5176 (thank you @ibc)