René's URL Explorer Experiment


Title: Better scope management for async code · Issue #3751 · getsentry/sentry-javascript · GitHub

Open Graph Title: Better scope management for async code · Issue #3751 · getsentry/sentry-javascript

X Title: Better scope management for async code · Issue #3751 · getsentry/sentry-javascript

Description: Currently, the @sentry/browser SDK has no mechanism to automatically clone the Hub (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 ha...

Open Graph Description: Currently, the @sentry/browser SDK has no mechanism to automatically clone the Hub (and, consequently, Scope), unlike @sentry/node that automatically clones a new hub per Node Domain -- and we use ...

X Description: Currently, the @sentry/browser SDK has no mechanism to automatically clone the Hub (and, consequently, Scope), unlike @sentry/node that automatically clones a new hub per Node Domain -- and we use ...

Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/3751

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Better scope management for async code","articleBody":"Currently, the `@sentry/browser` SDK has no mechanism to automatically clone the `Hub` (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.\r\n\r\nThis 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.\r\n\r\nThis issue tracks improving automatic hub/scope management/propagation in `@sentry/browser`. As a possible solution we may use (an optional support for) Zone.js.\r\n\r\nFor example:\r\n\r\n```js\r\nsetTag('a', 'tag');\r\nwithScope((scope) => {\r\n  setTimeout(() => {\r\n    captureMessage('test'); // no tags\r\n  }, 0);\r\n});\r\ngetCurrentHub().getScope().clear();\r\n```\r\n\r\n```js\r\nhub.withScope(async scope => {\r\n  console.log('scope1', scope);\r\n  scope.setTag('me', 'you');\r\n  hub.withScope(async scope => {\r\n    // will have tag me: you\r\n    console.log('scope2', scope);\r\n    await asyncOperation();\r\n    hub.withScope(async scope => {\r\n      // won't have tag me: you\r\n      console.log('scope3', scope);\r\n      await asyncOperation();\r\n    });\r\n  });\r\n});\r\n```\r\n\r\nThe problem is apparent when some code needs to get something from the current scope, for example here is our `fetch` instrumentation:\r\n\r\nhttps://github.com/getsentry/sentry-javascript/blob/61eda62ed5df5654f93e34a4848fc9ae3fcac0f7/packages/tracing/src/browser/request.ts#L169-L178\r\nhttps://github.com/getsentry/sentry-javascript/blob/61eda62ed5df5654f93e34a4848fc9ae3fcac0f7/packages/tracing/src/utils.ts#L54-L56\r\n\r\nBecause `fetch` is async, the \"current scope\" is not necessarily in the state that one would expect. In the example above, when we call `getActiveTransaction()`, the current hub/scope may have changed and lost reference to the current transaction.","author":{"url":"https://github.com/rhcarvalho","@type":"Person","name":"rhcarvalho"},"datePublished":"2021-06-25T14:05:36Z","url":"https://github.com/getsentry/sentry-javascript/issues/3751"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e57e951e-84b8-d773-55fa-d8280f82ee01
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id86A2:560C3:21608C:2DF043:6B04B712
html-safe-noncea71734c18103a0efad7b9607f92d7c041cc556985cbe9918c652ea4534cd62fa
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NkEyOjU2MEMzOjIxNjA4QzoyREYwNDM6NkIwNEI3MTIiLCJ2aXNpdG9yX2lkIjoiMzAzNjA5NDE1MTIwMTY5OTYwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacfb3067f5a970e0b6583504e19b23d5ddcf8d4dda6bb4578d0f964123f0798545
hovercard-subject-tagissue:930208020
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/3751/issue_layout
twitter:imagehttps://opengraph.githubassets.com/16686353d5cbbf3861274a18dc57237ce3f0c946afa65f65a1d89d627f2a2d88/getsentry/sentry-javascript/issues/3751
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/16686353d5cbbf3861274a18dc57237ce3f0c946afa65f65a1d89d627f2a2d88/getsentry/sentry-javascript/issues/3751
og:image:altCurrently, the @sentry/browser SDK has no mechanism to automatically clone the Hub (and, consequently, Scope), unlike @sentry/node that automatically clones a new hub per Node Domain -- and we use ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerhcarvalho
hostnamegithub.com
expected-hostnamegithub.com
None378bd702ac792b3550e484ad39d9a898fcd25bb52ba6962b0c9cc457c1ea71c7
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id3328572
octolytics-dimension-repository_nwogetsentry/sentry-javascript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id3328572
octolytics-dimension-repository_network_root_nwogetsentry/sentry-javascript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseb032e77f1ea437ede6c115446a0a467709b468e7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-javascript/issues/3751#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-javascript%2Fissues%2F3751
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-javascript%2Fissues%2F3751
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-javascript
Reloadhttps://github.com/getsentry/sentry-javascript/issues/3751
Reloadhttps://github.com/getsentry/sentry-javascript/issues/3751
Reloadhttps://github.com/getsentry/sentry-javascript/issues/3751
getsentryhttps://github.com/getsentry
sentry-javascripthttps://github.com/getsentry/sentry-javascript
Codehttps://github.com/getsentry/sentry-javascript
Issues333 (333)https://github.com/getsentry/sentry-javascript/issues
Pull requests49 (49)https://github.com/getsentry/sentry-javascript/pulls
Discussionshttps://github.com/getsentry/sentry-javascript/discussions
Actionshttps://github.com/getsentry/sentry-javascript/actions
Security and quality7 (7)https://github.com/getsentry/sentry-javascript/security
Insightshttps://github.com/getsentry/sentry-javascript/insights
https://github.com/getsentry/sentry-javascript
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/3751
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/3751
Better scope management for async codehttps://github.com/getsentry/sentry-javascript/issues/3751#top
Meta: Breakinghttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Meta%3A%20Breaking%22
Type: Improvementhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Type%3A%20Improvement%22
8.0.0https://github.com/getsentry/sentry-javascript/milestone/15
https://github.com/rhcarvalho
rhcarvalhohttps://github.com/rhcarvalho
on Jun 25, 2021https://github.com/getsentry/sentry-javascript/issues/3751#issue-930208020
sentry-javascript/packages/tracing/src/browser/request.tshttps://github.com/getsentry/sentry-javascript/blob/61eda62ed5df5654f93e34a4848fc9ae3fcac0f7/packages/tracing/src/browser/request.ts#L169-L178
61eda62https://github.com/getsentry/sentry-javascript/commit/61eda62ed5df5654f93e34a4848fc9ae3fcac0f7
sentry-javascript/packages/tracing/src/utils.tshttps://github.com/getsentry/sentry-javascript/blob/61eda62ed5df5654f93e34a4848fc9ae3fcac0f7/packages/tracing/src/utils.ts#L54-L56
61eda62https://github.com/getsentry/sentry-javascript/commit/61eda62ed5df5654f93e34a4848fc9ae3fcac0f7
Nexthttps://github.com/getsentry/sentry-javascript/issues/3751?timeline_page=1
AbhiPrasadhttps://github.com/AbhiPrasad
Status: Blockedhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Status%3A%20Blocked%22
Meta: Breakinghttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Meta%3A%20Breaking%22
Type: Improvementhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Type%3A%20Improvement%22
on Oct 4, 2021https://github.com/getsentry/sentry-javascript/issues/3751#event-5404422624
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Oct 25, 2021https://github.com/getsentry/sentry-javascript/issues/3751#issuecomment-951023180
github-actionshttps://github.com/apps/github-actions
Status: Stalehttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Status%3A%20Stale%22
on Oct 25, 2021https://github.com/getsentry/sentry-javascript/issues/3751#event-5514337914
rhcarvalhohttps://github.com/rhcarvalho
Status: Backloghttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Status%3A%20Backlog%22
Status: Stalehttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Status%3A%20Stale%22
on Oct 25, 2021https://github.com/getsentry/sentry-javascript/issues/3751#event-5514361797
smeubankhttps://github.com/smeubank
Workflow 2.0: JS Improvement for Grouping Errorshttps://github.com/getsentry/sentry-javascript/milestone/17
on Jun 20, 2022https://github.com/getsentry/sentry-javascript/issues/3751#event-6839528872
https://github.com/hanayashiki
hanayashikihttps://github.com/hanayashiki
on Aug 8, 2022https://github.com/getsentry/sentry-javascript/issues/3751#issuecomment-1207766215
smeubankhttps://github.com/smeubank
timfishhttps://github.com/timfish
onurtemizkanhttps://github.com/onurtemizkan
on Nov 23, 2022https://github.com/getsentry/sentry-javascript/issues/3751#event-7875979663
https://github.com/timfish
timfishhttps://github.com/timfish
on Dec 2, 2022https://github.com/getsentry/sentry-javascript/issues/3751#issuecomment-1335209173
herehttps://develop.sentry.dev/sdk/research/performance/#scope-propagation
timfishhttps://github.com/timfish
timfishhttps://github.com/timfish
onurtemizkanhttps://github.com/onurtemizkan
on Dec 4, 2022https://github.com/getsentry/sentry-javascript/issues/3751#event-7947665435
https://github.com/nealoke
nealokehttps://github.com/nealoke
on Mar 24, 2023https://github.com/getsentry/sentry-javascript/issues/3751#issuecomment-1482627419
rabbit hole explorationhttps://github.com/getsentry/sentry-javascript/issues/4947#issuecomment-1482622529
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀https://github.com/orgs/getsentry/projects/76
on Jun 24, 2023https://github.com/getsentry/sentry-javascript/issues/3751#event-14609989567
https://github.com/Lms24
Lms24https://github.com/Lms24
on Jun 26, 2023https://github.com/getsentry/sentry-javascript/issues/3751#issuecomment-1606903418
@ccarsehttps://github.com/ccarse
github-actionshttps://github.com/apps/github-actions
Waiting for: Teamhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Team%22
on Jun 26, 2023https://github.com/getsentry/sentry-javascript/issues/3751#event-9635188510
https://github.com/ccarse
ccarsehttps://github.com/ccarse
on Jun 26, 2023https://github.com/getsentry/sentry-javascript/issues/3751#issuecomment-1607400298
github-actionshttps://github.com/apps/github-actions
Waiting for: Teamhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Team%22
on Jun 26, 2023https://github.com/getsentry/sentry-javascript/issues/3751#event-9638512654
hubertdeng123https://github.com/hubertdeng123
Status: Blockedhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Status%3A%20Blocked%22
Status: Backloghttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Status%3A%20Backlog%22
on Jul 25, 2023https://github.com/getsentry/sentry-javascript/issues/3751#event-9914447580
AbhiPrasadhttps://github.com/AbhiPrasad
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
Waiting for: Teamhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Team%22
on Jul 28, 2023https://github.com/getsentry/sentry-javascript/issues/3751#event-9948274898
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀https://github.com/orgs/getsentry/projects/76
on Jul 28, 2023https://github.com/getsentry/sentry-javascript/issues/3751
Lms24https://github.com/Lms24
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Aug 3, 2023https://github.com/getsentry/sentry-javascript/issues/3751#event-9996909214
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀https://github.com/orgs/getsentry/projects/76
on Aug 3, 2023https://github.com/getsentry/sentry-javascript/issues/3751
AbhiPrasadhttps://github.com/AbhiPrasad
Workflow 2.0: JS Improvement for Grouping Errorshttps://github.com/getsentry/sentry-javascript/milestone/17
8.0.0https://github.com/getsentry/sentry-javascript/milestone/15
on Mar 6, 2024https://github.com/getsentry/sentry-javascript/issues/3751#event-12029100190
AbhiPrasadhttps://github.com/AbhiPrasad
completedhttps://github.com/getsentry/sentry-javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Apr 10, 2024https://github.com/getsentry/sentry-javascript/issues/3751#event-12427643361
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-javascript/issues/3751
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/3751
Meta: Breakinghttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Meta%3A%20Breaking%22
Type: Improvementhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Type%3A%20Improvement%22
GitHub Issues with 👀https://github.com/orgs/getsentry/projects/76
8.0.0https://github.com/getsentry/sentry-javascript/milestone/15
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.