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(node): Don't overwrite local variables for re-thrown errors #13644

Merged
merged 4 commits into from
Sep 13, 2024

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Sep 10, 2024

Closes #13416

Another way to fix this issue would be to check via the debugger if the property exists already on the error object and bail early before we have local variables. However, this would add an extra round trip call via the debugger for every error. Since re-thrown errors are far less likely, I decided instead to just not overwrite existing local variables.

This PR also adds a Debugger.resume call in the catch case to ensure that they debugger will always resume even if we get errors while debugging.

It's worth noting that this only fixes the issue in Node v20+ where we use the async debugging interface.

Copy link
Contributor

github-actions bot commented Sep 10, 2024

size-limit report 📦

Path Size % Change Change
@sentry/browser 22.52 KB - -
@sentry/browser - with treeshaking flags 21.3 KB - -
@sentry/browser (incl. Tracing) 34.79 KB - -
@sentry/browser (incl. Tracing, Replay) 71.25 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 61.69 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 75.59 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 88.32 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 90.16 KB - -
@sentry/browser (incl. metrics) 26.83 KB - -
@sentry/browser (incl. Feedback) 39.6 KB - -
@sentry/browser (incl. sendFeedback) 27.19 KB - -
@sentry/browser (incl. FeedbackAsync) 31.9 KB - -
@sentry/react 25.28 KB - -
@sentry/react (incl. Tracing) 37.75 KB - -
@sentry/vue 26.72 KB - -
@sentry/vue (incl. Tracing) 36.66 KB - -
@sentry/svelte 22.66 KB - -
CDN Bundle 23.77 KB - -
CDN Bundle (incl. Tracing) 36.49 KB - -
CDN Bundle (incl. Tracing, Replay) 70.95 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 76.26 KB - -
CDN Bundle - uncompressed 69.65 KB - -
CDN Bundle (incl. Tracing) - uncompressed 108.23 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 220.01 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 233.21 KB - -
@sentry/nextjs (client) 37.51 KB - -
@sentry/sveltekit (client) 35.36 KB - -
@sentry/node 120.53 KB +0.03% +32 B 🔺
@sentry/node - without tracing 92.81 KB +0.04% +31 B 🔺
@sentry/aws-serverless 102.51 KB +0.03% +27 B 🔺

View base workflow run

@timfish timfish marked this pull request as draft September 10, 2024 10:10
Comment on lines +161 to +164
async _ => {
if (isPaused) {
await session.post('Debugger.resume');
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea to add some more resiliency.

Comment on lines +121 to +123
functionDeclaration: `function() { this.${LOCAL_VARIABLES_KEY} = this.${LOCAL_VARIABLES_KEY} || ${JSON.stringify(
frames,
)}; }`,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love how simple this change is now after the redesign.
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shame it doesn't appear to work now I'm adding a test for it!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no, I forgot the recent changes only fix this issue in Node v20+ 🤦🏻‍♂️

@timfish timfish marked this pull request as ready for review September 10, 2024 10:41
@AbhiPrasad AbhiPrasad merged commit bcd2a17 into develop Sep 13, 2024
112 checks passed
@AbhiPrasad AbhiPrasad deleted the timfish/fix/dont-overwrite-local-variables branch September 13, 2024 08:42
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.

LocalVariables integration - re-thrown errors can completely mess up frame variables
3 participants