-
-
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
Better scope management for async code #3751
Comments
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
hope this can get some attention |
More details of the scope propagation issues are documented here. |
For anybody that had issues with this and is looking for a solution with a decent explanation look at my rabbit hole exploration. I don't understand these things are not properly mentioned or explained in the docs. I've been setting up Sentry for about 30 hours now and the docs have often been poor if you are not having a vanilla express setup 😢. |
Are there any plans on addressing this? Out of the box my lambdas events are highly polluted by other events. |
Hey @ccarse can you elaborate a bit more on how your events are polluted? Maybe there's something we can improve. |
Turns out I was missing an await on an event handler and that was causing the issue. Once I fixed that it looks good now. Thanks! |
Currently, the
@sentry/browser
SDK has no mechanism to automatically clone theHub
(and, consequently,Scope
), unlike@sentry/node
that automatically clones a new hub per Node Domain -- and we use that to isolate state for Node server handling concurrent requests.This means that, in particular for
@sentry/browser
, any kind of async code may end up accidentally mixing up state unless hubs are manually cloned and used per unit of concurrency.This issue tracks improving automatic hub/scope management/propagation in
@sentry/browser
. As a possible solution we may use (an optional support for) Zone.js.For example:
The problem is apparent when some code needs to get something from the current scope, for example here is our
fetch
instrumentation:sentry-javascript/packages/tracing/src/browser/request.ts
Lines 169 to 178 in 61eda62
sentry-javascript/packages/tracing/src/utils.ts
Lines 54 to 56 in 61eda62
Because
fetch
is async, the "current scope" is not necessarily in the state that one would expect. In the example above, when we callgetActiveTransaction()
, the current hub/scope may have changed and lost reference to the current transaction.The text was updated successfully, but these errors were encountered: