-
-
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
Context not being reliably set in withScope. Potential v7 regression. #5261
Comments
Hi @sacummings91 and thanks for writing in! The reason I'm asking is because it could have something to do with this line here which I'm suspecting to be ditching contexts as soon as we have a sentry-javascript/packages/core/src/baseclient.ts Lines 507 to 508 in 3a938aa
In case this has something to do with it, #5218 might just fix this issue. But I might be off here, so any additional unformation you can provide would be appreciated. For example, can you show your |
Hey @Lms24, thanks for getting to this. Yeah, to clarify, if we send the context every time it only makes it to sentry.io like 1/5 of the times. It is the same situations. I have been testing it to be sure. This is also something that only started happening when we upgraded to v7. The weirdest part to me is that the latter 2 code snippets I posted work 100% of the time. Which makes it feel like a weird race condition or something. The PR you posted definitely looks like it could be related the problem too. Sentry.init here:
|
Following up on Lukas's work, I made a quick reproduction of your setup, but I was always able to see context attached to events: https://codesandbox.io/s/withscope-context-v7-97eegl?file=/src/index.js A couple of things to note:
sentry-javascript/packages/types/src/hub.ts Line 165 in 3a938aa
In the reproduction above, I removed
if (options?.context) {
const contexts = options.context;
for (const key in contexts) {
scope.setContext(key, contexts[key]);
}
} |
Hey @AbhiPrasad, the name of
The link to the sentry event in the original post also shows what it looks like when it's working properly and getting passed sentry.io. If you click the link you can see there is a "context" section and it's not all under one key. Here's another example with some more complex values: https://sentry.io/organizations/ternary/issues/3329348637/?environment=production&project=5634786&query=is%3Aunresolved&statsPeriod=14d#context-context I will try the |
Hey @AbhiPrasad I'm testing some events with |
Ok I just did some logging in the Sentry source code and can confirm that sentry-javascript/packages/core/src/baseclient.ts Lines 507 to 508 in 3a938aa
Do you guys have any idea what version the fix for this is planned to be released in? |
Good catch! We'll be fixing this ASAP and cutting a release very soon. |
This should be fixed by |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
@sentry/react
SDK Version
7.1.1
Framework Version
7.1.1
Link to Sentry event
https://sentry.io/organizations/ternary/issues/3191835938/?environment=test&project=5634786&query=is%3Aunresolved
Steps to Reproduce
I have a small class that wraps sentry for capturing messages and exceptions. As shown below, for some reason, context does not get reliably sent.
Below are two examples where it works every time. And I do not understand why.
If I do anything extra like this console log:
Or even just setting context to a new variable first like this:
Is this a bug with 7.0? This didn't happen before I upgraded.
Expected Result
Custom context should show up on issue in Sentry.io console
Actual Result
Custom context does not show up in Sentry.io console
The text was updated successfully, but these errors were encountered: