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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/node/src/integrations/local-variables/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@
// We write the local variables to a property on the error object. These can be read by the integration as the error
// event pass through the SDK event pipeline
await session.post('Runtime.callFunctionOn', {
functionDeclaration: `function() { this.${LOCAL_VARIABLES_KEY} = ${JSON.stringify(frames)}; }`,
functionDeclaration: `function() { this.${LOCAL_VARIABLES_KEY} = this.${LOCAL_VARIABLES_KEY} || ${JSON.stringify(
frames,
)}; }`,
Dismissed Show dismissed Hide dismissed
Comment on lines +121 to +123

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+ 🤦🏻‍♂️

silent: true,
objectId,
});
Expand Down Expand Up @@ -156,8 +158,10 @@
}, 1_000);
}
},
_ => {
// ignore any errors
async _ => {
if (isPaused) {
await session.post('Debugger.resume');
}
Comment on lines +161 to +164

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.

},
);
});
Expand Down
Loading