fix(node): Use unique variable for ANR context transfer#11161
Merged
AbhiPrasad merged 3 commits intodevelopfrom Mar 18, 2024
Merged
fix(node): Use unique variable for ANR context transfer#11161AbhiPrasad merged 3 commits intodevelopfrom
AbhiPrasad merged 3 commits intodevelopfrom
Conversation
Contributor
size-limit report 📦
|
delaneyb
reviewed
Mar 18, 2024
Comment on lines
176
to
177
| expression: | ||
| 'const ctx = __SENTRY__.acs?.getCurrentScope().getPropagationContext() || {}; ctx.traceId + "-" + ctx.spanId + "-" + ctx.parentSpanId', | ||
| 'const __sentry_ctx = __SENTRY__.acs?.getCurrentScope().getPropagationContext() || {}; __sentry_ctx.traceId + "-" + __sentry_ctx.spanId + "-" + __sentry_ctx.parentSpanId', | ||
| // Don't re-trigger the debugger if this causes an error |
There was a problem hiding this comment.
Whatever context this is evaluated in, the next time the same Runtime.evaluate is used (assuming support for multiple ANR captures is added), won't this potentially just lead to the same conflicting variable issue due to it now being defined from the last time Runtime.evaluate defined it? Here was my solution:
const t = Date.now()
// Evaluate a script in the currently paused context
session.post('Runtime.evaluate', {
// Grab the trace context from the current scope
expression: `const ctx_${t} = __SENTRY__.acs?.getCurrentScope().getPropagationContext() || {}; ctx_${t}.traceId + "-" + ctx_${t}.spanId + "-" + ctx_${t}.parentSpanId`,
// Don't re-trigger the debugger if this causes an error
silent: true,
}, (err, param) => {Just using var instead of const with your __sentry_ctx would also work?
AbhiPrasad
approved these changes
Mar 18, 2024
AbhiPrasad
pushed a commit
that referenced
this pull request
Mar 18, 2024
cadesalaberry
pushed a commit
to cadesalaberry/sentry-javascript
that referenced
this pull request
Apr 19, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11147