Repository navigation
chore(deps): pin the Sentry SDK to 10.56.0 to fix the span/scope memory leak - #2101
Merged
Merged
Conversation
…leak fix The installed SDK (10.45.0) has a memory leak in @sentry/core: spans and scopes reference each other circularly and cannot be garbage collected, and the span exporter keeps sent spans in an unbounded map. Upstream tracked it as "Memory leak with high tracesSampleRate" (getsentry/sentry-javascript#18339) and fixed it in 10.56.0 (getsentry/sentry-javascript#21242). 10.56.0 also carries the 10.49.0 fix for contexts retained through scopes on pooled connections (getsentry/sentry-javascript#20328). This matches what we saw in production: the MCP service climbed to the V8 heap limit about once a day while trace sampling was 100%, and the climb stopped when #2082 cut sampling to 20%. Sampling less only slows the leak; this fixes it at the source, for the backend, the orchestrator and the frontend server alike. Pinned exactly, not with a caret, on purpose. 10.56.0 is the first release with the fix, and later minors change behaviour we have not evaluated: 10.61.0 streams gen_ai spans by default and stops truncating AI message data, 10.71.0 enables logs by default, 10.72.0 stops reporting AI errors that propagate to the caller. The lockfile was regenerated from the committed one with only these four specifiers changed; the rest of the diff is Sentry's own dependency tree (several OpenTelemetry instrumentations are now vendored and drop out). @sentry/webpack-plugin keeps its own build-time @sentry/core copy. Behaviour changes that do ride along (10.46.0 to 10.56.0): OpenAI span attributes are renamed from openai.* to gen_ai.* (10.48.0), the NestJS instrumentation is vendored inside the SDK (10.54.0), array attribute values are sent as arrays (10.54.0). sendDefaultPii, which the frontend init uses, is deprecated in 10.57.0 and is untouched here. Testing on 10.56.0, against a Sentry development environment unless noted: - backend, orchestrator and frontend type-check; backend and orchestrator boot; production `next build` passes, also when the source-map upload fails (the next.config error handler absorbs it) - backend: HTTP transactions, console logs, an unhandled controller 500 through the Nest global filter with the organization tag, a process level crash, Sentry.metrics counters and profiler ids on spans - frontend: client init with every configured integration, user and organization tag, an uncaught browser error linked to its session replay, the crash report dialog, the feedback form, pageload spans with browser profiles - OpenAI integration against a local stub: the wrapped client works for chat.completions.create and .parse; create emits a gen_ai.chat span; .parse and images.generate are not instrumented on 10.45.0 either - MCP flows (initialize, tools/list, tools/call) unchanged Not tested: a successful source-map upload to the real project. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Strix Security ReviewNo security issues found. Updated for Reviewed by Strix |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This was referenced Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Dependency update (backend, orchestrator and frontend, Sentry SDK). Pins
@sentry/nestjs,@sentry/nextjs,@sentry/profiling-nodeand@sentry/reactto exactly10.56.0in the rootpackage.json(previously^10.2x, locked at 10.45.0) and regeneratespnpm-lock.yaml. No application code changes. The lockfile was regenerated from the committed one with only these four specifiers changed; the rest of its diff is Sentry's own dependency tree, where several OpenTelemetry instrumentations are now vendored and drop out.@sentry/webpack-pluginkeeps its own build-time copy of@sentry/core.Why was this change needed?
To fix the SDK memory leak at the source. The locked SDK (10.45.0) has a leak in
@sentry/core: spans and scopes reference each other circularly and cannot be garbage collected, and the span exporter keeps sent spans in an unbounded map. Upstream tracked it as "Memory leak with high tracesSampleRate" (getsentry/sentry-javascript#18339) and fixed it in 10.56.0 (getsentry/sentry-javascript#21242). 10.56.0 also includes the 10.49.0 fix for contexts retained through scopes on pooled connections (getsentry/sentry-javascript#20328).This matches what we saw in production. The MCP service climbed to V8's heap limit (about 3.4 GB) roughly once a day while trace sampling was 100%, and the climb stopped on the day #2082 cut sampling to 20%. Sampling less only slows the leak. The leak is in the core package, so the backend, the orchestrator and the frontend server all carry it; the MCP service showed it first because it holds hundreds of long-lived transactions open (see #1850 and #2100).
Other information:
The pin is exact on purpose. 10.56.0 is the first release with the fix, and later minors change behaviour we have not evaluated: 10.61.0 streams
gen_aispans by default and stops truncating AI message data, 10.71.0 enables logs by default, and 10.72.0 stops reporting AI errors that propagate to the caller. A caret range would let a laterpnpm uppull those in silently.Behaviour changes that do come along between 10.46.0 and 10.56.0, from the changelog (https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md):
openai.*togen_ai.*. Only matters if a Sentry dashboard or alert filters on the old names.sendDefaultPii, which the frontend init uses, is deprecated in 10.57.0 and is not affected by this PR.This PR is independent of #1850 (answer MCP stream GETs with 405) and #2100 (stop tracing those GETs) and can merge in any order relative to them.
Leak test: 10.45.0 vs 10.56.0
To confirm the fix rather than take the changelog's word for it, both versions of
@sentry/nodewere installed in isolation and run side by side: the same small HTTP server, each request creating one span with four nested child spans,tracesSampleRate: 1.0, events sent to a sink that accepts and discards them. Both received identical load, 200 requests per second for 6 minutes (71,280 requests each, 0 errors), followed by more than 6 minutes idle. Heap isheapUsedmeasured right after a forced garbage collection, so it is retained memory, not garbage waiting to be collected.QA
pnpm install --frozen-lockfileand confirm it passes, then confirmnode_modules/@sentry/nestjs/package.jsonandnode_modules/@sentry/nextjs/package.jsonboth say 10.56.0setTimeout(() => { throw new Error('sdk-bump-check') }, 0). The "It looks like we're having issues" report dialog should appear; close itGET /public/v1/integrationswith an API keysdk-bump-checkerror is present with the user, theorganization.idtag and a linked replay; backendhttp.servertransactions and frontendpageloadtransactions withsdk.version:10.56.0; backend log entries; thepublic_api_requestmetricpnpm run build:frontendand confirm it exits 0Results of the testing already done on 10.56.0 (against a Sentry development environment unless noted):
next buildpasses, also when the source-map upload fails (thenext.config.jserror handler absorbs it).Sentry.metricscounters, profiler ids on spans.chat.completions.createand.parse, andcreateemits agen_ai.chatspan..parseandimages.generateare not instrumented on 10.45.0 either, so nothing changes there.initialize,tools/list,tools/call) unchanged.Checklist:
Put a "X" in the boxes below to indicate you have followed the checklist;
🤖 Generated with Claude Code