Skip to content

fix(core): Capture scopes on span before emitting spanStart event#21644

Merged
andreiborza merged 1 commit into
developfrom
ab/scope-capture-ordering
Jun 18, 2026
Merged

fix(core): Capture scopes on span before emitting spanStart event#21644
andreiborza merged 1 commit into
developfrom
ab/scope-capture-ordering

Conversation

@andreiborza

Copy link
Copy Markdown
Member

Move setCapturedScopesOnSpan into _startRootSpan and _startChildSpan so the captured scope/isolation scope are present on the span when spanStart listeners fire.

Previously they were set after createChildOrRootSpan returned, so listeners reading getCapturedScopesOnSpan (e.g. to fork the isolation scope) saw stale data and their changes were overwritten.

Move `setCapturedScopesOnSpan` into `_startRootSpan` and `_startChildSpan` so
the captured scope/isolation scope are present on the span when `spanStart`
listeners fire.

Previously they were set after `createChildOrRootSpan` returned,
so listeners reading `getCapturedScopesOnSpan` (e.g. to fork the isolation scope)
saw stale data and their changes were overwritten.
@andreiborza andreiborza requested review from Lms24 and logaretm June 18, 2026 18:09
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.45 kB - -
@sentry/browser - with treeshaking flags 25.88 kB - -
@sentry/browser (incl. Tracing) 45.91 kB +0.05% +21 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.16 kB +0.08% +38 B 🔺
@sentry/browser (incl. Tracing, Profiling) 50.69 kB +0.05% +22 B 🔺
@sentry/browser (incl. Tracing, Replay) 85.1 kB +0.03% +20 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.71 kB +0.03% +22 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 89.8 kB +0.03% +20 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 102.47 kB +0.02% +19 B 🔺
@sentry/browser (incl. Feedback) 44.62 kB - -
@sentry/browser (incl. sendFeedback) 32.25 kB - -
@sentry/browser (incl. FeedbackAsync) 37.38 kB - -
@sentry/browser (incl. Metrics) 28.52 kB - -
@sentry/browser (incl. Logs) 28.76 kB - -
@sentry/browser (incl. Metrics & Logs) 29.45 kB - -
@sentry/react 29.25 kB - -
@sentry/react (incl. Tracing) 48.21 kB +0.06% +28 B 🔺
@sentry/vue 32.58 kB +0.07% +20 B 🔺
@sentry/vue (incl. Tracing) 47.78 kB +0.06% +24 B 🔺
@sentry/svelte 27.48 kB - -
CDN Bundle 29.86 kB - -
CDN Bundle (incl. Tracing) 48.32 kB +0.05% +23 B 🔺
CDN Bundle (incl. Logs, Metrics) 31.4 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.62 kB +0.05% +21 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 70.71 kB - -
CDN Bundle (incl. Tracing, Replay) 85.64 kB +0.03% +20 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.9 kB +0.02% +17 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.49 kB +0.03% +22 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.73 kB +0.03% +20 B 🔺
CDN Bundle - uncompressed 88.8 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.13 kB +0.03% +41 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.5 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.1 kB +0.03% +41 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.33 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.99 kB +0.02% +41 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.95 kB +0.02% +41 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.69 kB +0.02% +41 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.64 kB +0.02% +41 B 🔺
@sentry/nextjs (client) 50.61 kB +0.05% +25 B 🔺
@sentry/sveltekit (client) 46.3 kB +0.06% +24 B 🔺
@sentry/core/server 76.19 kB +0.04% +23 B 🔺
@sentry/core/browser 63.34 kB +0.04% +24 B 🔺
@sentry/node-core 61.88 kB +0.03% +14 B 🔺
@sentry/node 124.67 kB +0.02% +21 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.05 kB - -
@sentry/node/light 50.96 kB +0.06% +29 B 🔺
@sentry/node - without tracing 74.26 kB +0.03% +22 B 🔺
@sentry/aws-serverless 85.35 kB +0.01% +3 B 🔺
@sentry/cloudflare (withSentry) - minified 174.52 kB +0.03% +39 B 🔺
@sentry/cloudflare (withSentry) 436.81 kB +0.06% +259 B 🔺

View base workflow run

@andreiborza andreiborza merged commit 506b0d6 into develop Jun 18, 2026
528 of 541 checks passed
@andreiborza andreiborza deleted the ab/scope-capture-ordering branch June 18, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants