Title: Memory leak: frozen Nest `Create Nest App` span retains unbounded `_sentryChildSpans` (SDK ≥10.64; mitigated by `openTelemetryBasicTracerProvider: true`, which #22557 removes) · Issue #22860 · getsentry/sentry-javascript · GitHub
Open Graph Title: Memory leak: frozen Nest `Create Nest App` span retains unbounded `_sentryChildSpans` (SDK ≥10.64; mitigated by `openTelemetryBasicTracerProvider: true`, which #22557 removes) · Issue #22860 · getsentry/sentry-javascript
X Title: Memory leak: frozen Nest `Create Nest App` span retains unbounded `_sentryChildSpans` (SDK ≥10.64; mitigated by `openTelemetryBasicTracerProvider: true`, which #22557 removes) · Issue #22860 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/22860
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Memory leak: frozen Nest `Create Nest App` span retains unbounded `_sentryChildSpans` (SDK ≥10.64; mitigated by `openTelemetryBasicTracerProvider: true`, which #22557 removes)","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSelf-hosted/on-premise\n\n### Which SDK are you using?\n\n@sentry/nestjs\n\n### SDK Version\n\n10.66.0\n\n### Framework Version\n\nNestJS 11\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\nSDK ≥10.64\n\n`Sentry.init({\n debug: false,\n dsn: config.SENTRY_DSN,\n enabled: isPreproductionOrProduction(),\n enableMetrics: false,\n tracesSampleRate: 0,\n environment: config.NODE_ENV,\n release: version,\n})`\n\n### Steps to Reproduce\n\n1. Nest app with `@sentry/nestjs` (SDK ≥10.64) + `SentryModule.forRoot()`, `Sentry.init({ tracesSampleRate: 0 })`\n2. Run under sustained HTTP / messaging load for ≥1h\n3. Force GC and compare `old_space` / take heap snapshots\n\n### Expected Result\n\n- An ended / frozen span should not keep accumulating children, **or**\n- `_sentryChildSpans` should be cleared / bounded when a span ends, **or**\n- Bootstrap / `app_creation` spans should not remain active parents after Nest boot completes\n\n### Actual Result\n\nEnded `Create Nest App` span retains an unbounded `_sentryChildSpans` set for process lifetime → continuous `Scope` / `SentryNonRecordingSpan` growth even with `tracesSampleRate: 0`.\n\n### Additional Context\n\nAfter upgrading from `@sentry/nestjs@10.62.0`, a long-lived Nest service’s JS heap grew ~**80 MB/h** under production traffic and never reclaimed on forced GC.\n\nHeap snapshots ~ 70 minutes apart showed almost 1:1 growth of `Scope` and `SentryNonRecordingSpan` (~ +176k each). Retention was dominated by a single root span:\n\n- **name:** `Create Nest App`\n- **op / attrs:** `app_creation.nestjs`, `sentry.origin=auto.http.otel.nestjs`, `nestjs.module=AppModule`\n- **`_sentryChildSpans`:** ~**154k** direct children (of ~233k total child links in the heap)\n- Span also carried **`sentry.tracerProviderSpan`** (marker for spans from Sentry’s minimal tracer provider)\n\nImportant: this root span was **already ended / frozen** (`_frozen: true`, `_status` set). It still kept receiving children via `addChildSpanToSpan` into a strong `Set` (`_sentryChildSpans`), so memory grew for the lifetime of the process.\n\nObserved constructor deltas (shallow, ~70 min):\n\n| Constructor | Δ count | Δ shallow |\n|---|---:|---:|\n| `Object` | +1.09M | +55 MB |\n| `Scope` | +176k | +31 MB |\n| `Array` | +709k | +22 MB |\n| `SentryNonRecordingSpan` | +176k | +19 MB |\n| `WeakRef` | +528k | +16 MB |\n\nDominant retainer shape:\n\n```\nScope ←_sentryScope— SentryNonRecordingSpan ←(Set)— _sentryChildSpans ← SentrySpan(\"Create Nest App\")\n```\n\nSame growth pattern appeared on a second service after the same SDK bump, at a lower rate matching lower traffic — points away from app-specific code.\n\n## Suspected regression\n\n**10.64.0** introduced default use of Sentry’s minimal `SentryTracerProvider` instead of the full OTel `BasicTracerProvider`:\n\n- [https://github.com/getsentry/sentry-javascript/blob/HEAD/CHANGELOG.md (10.64.0)](https://github.com/getsentry/sentry-javascript/blob/HEAD/CHANGELOG.md#10640)\n- PRs: https://github.com/getsentry/sentry-javascript/pull/21666, https://github.com/getsentry/sentry-javascript/pull/21680, https://github.com/getsentry/sentry-javascript/pull/21842\n\nThe leaking root is created by Nest instrumentation (`getAppCreationSpanOptions` / orchestrion `NESTJS_APP_CREATION` → `startInactiveSpan`). Children are attached via `addChildSpanToSpan` in `@sentry/core` with no guard for an already-ended parent and no upper bound on `_sentryChildSpans`.\n\nRelated prior discussion (different trigger, same “never-pruned root span” failure mode): https://github.com/getsentry/sentry-javascript/issues/13412 \nUpstream WeakRef work (#21242) is present in 10.66 but does **not** stop strong retention through `_sentryChildSpans`.\n\n## Workaround (confirmed on our prod)\n\n```ts\nSentry.init({\n // ...\n openTelemetryBasicTracerProvider: true,\n})\n```\n\nAfter deploying this, container memory on the affected Nest service returned to a flat profile.\n\nThe `httpIntegration({ ignoreOutgoingRequests: () => true })` workaround from #13412 does **not** apply: the accumulator is the Nest `app_creation` span, not an outgoing HTTP/WebSocket span.\n\n## Note on the workaround's lifetime\n\n`openTelemetryBasicTracerProvider: true` is currently our only mitigation. [#22557](https://github.com/getsentry/sentry-javascript/pull/22557) (merged to `develop`, not yet in a published release as of **10.69.0**) removes this option along with `SentrySpanProcessor` / `SentrySampler`.\n\nOnce that lands, TypeScript will reject the option as unknown. Deleting it to silence the error silently reintroduces the leak, because `initOtel` no longer has an opt-out and the minimal `SentryTracerProvider` becomes the only path.\n\nIf the accumulation is inherent to `SentryTracerProvider`, removing the opt-out leaves affected Nest services with no mitigation short of disabling Sentry. Relevant to the direction in [#22486](https://github.com/getsentry/sentry-javascript/issues/22486).\n\nHappy to provide redacted heap-snapshot excerpts / retainer dumps if needed.\n\n### Priority\n\n\u003csub>React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it.\u003c/sub>","author":{"url":"https://github.com/m3Lith","@type":"Person","name":"m3Lith"},"datePublished":"2026-07-30T11:57:26Z","url":"https://github.com/getsentry/sentry-javascript/issues/22860"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:98541914-6efb-dd3d-5b0c-e61b07a0be31 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A2FE:1B5E62:221207:2FAAB5:6B043936 |
| html-safe-nonce | 4003105180bb56356dd62055a7973e536f88003dd5ca50812021a9a2a7f90984 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkZFOjFCNUU2MjoyMjEyMDc6MkZBQUI1OjZCMDQzOTM2IiwidmlzaXRvcl9pZCI6IjIyNjU4NjY5NDE0NzY2NDkyNzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 91523bfab14e1a5530dbcb7a131096cf2d2f3a5ab28b99c9144c2ca2eaae605b |
| hovercard-subject-tag | issue:5019451611 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/22860/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d54b711c332d453350626433587a23969ba87006e20db8dbd663eb79b6daa5b7/getsentry/sentry-javascript/issues/22860 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d54b711c332d453350626433587a23969ba87006e20db8dbd663eb79b6daa5b7/getsentry/sentry-javascript/issues/22860 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | m3Lith |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width