Skip to content

Commit

Permalink
fix(node): Don't overwrite local variables for re-thrown errors
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Sep 10, 2024
1 parent 1285e4b commit 68a6e4c
Showing 1 changed file with 7 additions and 3 deletions.
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 @@ async function handlePaused(
// 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,
)}; }`,

Check warning

Code scanning / CodeQL

Improper code sanitization Medium

Code construction depends on an
improperly sanitized value
.
silent: true,
objectId,
});
Expand Down Expand Up @@ -156,8 +158,10 @@ async function startDebugger(): Promise<void> {
}, 1_000);
}
},
_ => {
// ignore any errors
async _ => {
if (isPaused) {
await session.post('Debugger.resume');
}
},
);
});
Expand Down

0 comments on commit 68a6e4c

Please sign in to comment.