fix(core): Bound child span tracking on long-lived spans - #22916
Open
andreiborza wants to merge 3 commits into
Open
fix(core): Bound child span tracking on long-lived spans#22916andreiborza wants to merge 3 commits into
andreiborza wants to merge 3 commits into
Conversation
A span keeps a strong reference to every child started under it, so a span that outlives its children retains all of them. In NestJS the `Create Nest App` span stays the active parent of anything a `setInterval` from a provider constructor starts, which retains every span for the lifetime of the process. Children are no longer tracked on an unsampled span, on a segment span whose tree has already been serialized, or past the 1000 spans a transaction can carry. Every child still records its root span, so late children are re-emitted as their own transaction as before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
size-limit report 📦
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c92f7f3. Configure here.
andreiborza
marked this pull request as ready for review
July 31, 2026 15:19
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
Bounds the child spans a span keeps a reference to. A child is no longer tracked when it could never show up in what that span sends:
Late children still resolve their root span, so they keep being sent on their own.
Why
A span that outlives its children retains every one of them. In NestJS the
Create Nest Appspan stays the active parent of anything asetIntervalfrom a provider constructor starts, so those spans are never released and the process leaks around 80 MB/h.Measured on a reproduction (60 s at 20 rps, post-GC heap snapshots), children retained on that span and heap node growth over the run:
Closes: #22860