-
-
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): Don't overwrite local variables for re-thrown errors #13644
fix(node): Don't overwrite local variables for re-thrown errors #13644
Conversation
size-limit report 📦
|
async _ => { | ||
if (isPaused) { | ||
await session.post('Debugger.resume'); | ||
} |
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.
good idea to add some more resiliency.
functionDeclaration: `function() { this.${LOCAL_VARIABLES_KEY} = this.${LOCAL_VARIABLES_KEY} || ${JSON.stringify( | ||
frames, | ||
)}; }`, |
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.
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.
Shame it doesn't appear to work now I'm adding a test for it!
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.
Ah no, I forgot the recent changes only fix this issue in Node v20+ 🤦🏻♂️
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.