Skip to content

fix(node): Move Async context strategy setup to NodeClient.init() - #23458

Open
timfish wants to merge 2 commits into
developfrom
timfish/fix/move-als-setup-to-init
Open

fix(node): Move Async context strategy setup to NodeClient.init()#23458
timfish wants to merge 2 commits into
developfrom
timfish/fix/move-als-setup-to-init

Conversation

@timfish

@timfish timfish commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

SDKs that can't reuse @sentry/node's init() (see getsentry/sentry-electron#1415) currently have to copy this wiring themselves: install the strategy and assign client.asyncLocalStorageLookup. With this change, constructing a NodeClient and calling client.init() is enough, matching what DenoClient.init() already does. The install runs before super.init() because channel-based integrations capture the strategy's AsyncLocalStorage via getTracingChannelBinding() during integration setup.

Nothing changes for existing consumers:

  • All framework SDKs funnel through @sentry/node's init(), which still installs the strategy exactly once per init, now via client.init(). There are no NodeClient subclasses.
  • Scope identity is unaffected by the later install. The stack fallback strategy seeds its scope with getDefaultCurrentScope(), the same object both server strategies fall back to, so initialScope and setClient still land on the same scope.
  • Manually constructed clients (the pattern from fix(node): Allow use of NodeClient without calling init #11585) previously got no strategy and no asyncLocalStorageLookup at all; now they get both.

timfish and others added 2 commits August 20, 2026 01:46
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.3 kB - -
@sentry/browser - with treeshaking flags 28.47 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.81 kB - -
@sentry/browser (incl. Tracing) 48.58 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.59 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.46 kB - -
@sentry/browser (incl. Tracing, Replay) 87.98 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.36 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.7 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.39 kB - -
@sentry/browser (incl. Feedback) 47.65 kB - -
@sentry/browser (incl. sendFeedback) 35.13 kB - -
@sentry/browser (incl. FeedbackAsync) 40.28 kB - -
@sentry/browser (incl. Metrics) 31.24 kB - -
@sentry/browser (incl. Logs) 31.52 kB - -
@sentry/browser (incl. Metrics & Logs) 32.15 kB - -
@sentry/react 32.09 kB - -
@sentry/react (incl. Tracing) 50.77 kB - -
@sentry/vue 35.34 kB - -
@sentry/vue (incl. Tracing) 50.54 kB - -
@sentry/svelte 30.33 kB - -
CDN Bundle 31.61 kB - -
CDN Bundle (incl. Tracing) 48.9 kB - -
CDN Bundle (incl. Logs, Metrics) 33.8 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.82 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.31 kB - -
CDN Bundle (incl. Tracing, Replay) 86.48 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.31 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.19 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.12 kB - -
CDN Bundle - uncompressed 93.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.75 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.44 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.08 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.01 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.71 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.37 kB - -
@sentry/nextjs (client) 53.29 kB - -
@sentry/sveltekit (client) 49 kB - -
@sentry/core/server 65.38 kB - -
@sentry/core/browser 51.72 kB - -
@sentry/node 117.43 kB +0.38% +436 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 81.91 kB +0.59% +475 B 🔺
@sentry/aws-serverless 91.34 kB +0.46% +413 B 🔺
@sentry/cloudflare (withSentry) - minified 213.98 kB - -
@sentry/cloudflare (withSentry) 528.93 kB - -

View base workflow run

@timfish
timfish marked this pull request as ready for review August 20, 2026 00:41
@timfish
timfish requested a review from a team as a code owner August 20, 2026 00:41
@timfish
timfish requested review from JPeer264, Lms24, msonnb and stephanie-anderson and removed request for a team and stephanie-anderson August 20, 2026 00: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.

1 participant