-
-
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
includeLocalVariables
fails to capture local variables across sync/async boundaries
#11194
Comments
Hey @andymccurdy thanks for writing in! @timfish when you have some time, would you mind taking a look? Thanks! |
We capture local variables for exceptions via the v8 debugging interface. When events are captured by the SDK we have to try and match the captured debugger stack frames to the Sentry frames which are parsed from It looks like the above issue is caused by the debugger stack frames not matching those parsed from |
@timfish FWIW this isn't just an issue with The repro case used |
In my testing, local variables were getting captured across async calls without issue, they just weren't all getting added to the frames in the Sentry event because the frames didn't match up exactly. When you call into http or database libraries, they are likely also creating promises which would cause the issue I have fixed. There could be other cases where the frames don't match which we haven't considered yet but we'd need to reproduce those too! |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
7.103.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
Full repro here: https://github.com/andymccurdy/sentry-node-koa-localvars
See README for instructions on installing and running.
I've tested on Node versions 18.19.1 and 20.11.1. Both versions produce identical behavior.
Expected Result
Local variables included in every stack frame
Actual Result
Local variables are only present on stack frames within the same async context where an error is thrown from. It is unclear if this is a symptom of #8928 or something different.
Sync Example:
The request handler
errorSync
and the subsequent sync functions it calls (someSyncFunc
,syncStepA
andsyncStepB
) all include local variables. However, no middleware functions (Koa internal or user defined) have local variables as they are all async.Async Example:
The request handler
errorAsync
await
s for the async functionsomeAsyncFunc
. Notice thatsomeAsyncFunc
,syncStepA
andsyncStepB
all include local variables as they are all executed in the same tick. However no local variables are included on theerrroAsync
request handler as it was executed in a prior iteration of the event loop. As with the sync example, no middleware functions (Koa internal or user defined) have local variables.The text was updated successfully, but these errors were encountered: