-
-
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
fix(node): Log entire error object in OnUncaughtException
#8876
Merged
Conversation
This file contains 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
OnUncaughtException
lforst
approved these changes
Aug 28, 2023
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.
Reasonable
packages/node-integration-tests/suites/public-api/OnUncaughtException/test.ts
Fixed
Show fixed
Hide fixed
size-limit report 📦
|
|
||
const testScriptPath = path.resolve(__dirname, 'log-entire-error-to-console.js'); | ||
|
||
childProcess.exec(`node ${testScriptPath}`, { encoding: 'utf8' }, (err, stderr) => { |
Check warning
Code scanning / CodeQL
Shell command built from environment values
This shell command depends on an uncontrolled [absolute path](1).
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.
In our
OnUncaughtException
integration, we have to emulate Node's default behaviour of logging errors to the console.For some reason though, we only logged the stack trace of an
error
with a stack trace instead of the entire error object.As reported in #8856, this causes additional properties on the error (such as
cause
) not to be logged anymore which doesn't reflect Node's default behaviour (see issue for comparison). This PR simplifies theconsole.error
call to just always log the entireerror
.I tried tracing back why we do this but it seems like we added this when moving from
raven-node
to@sentry/node
. I didn't find this before in Raven and there's no explanation as to why we started doing it in @sentry/node. So I guess it should be fine to change this.Side-node: As already mentioned in #1661 (comment), we should consider moving to
UnhandledExceptionMonitor
in v8, especially if we drop Node <=12 support.closes #8856
Update: Seems like
console.error(error)
only prints additional properties since Node 16. Nothing much we can do here so I adjusted the test to take this into accound.