Skip to content

fix(profiling-node): Stop the trace lifecycle profiler when spans are unsampled - #25210

Merged
s1gr1d merged 2 commits into
developfrom
sigridhuemer/js-3893-profiling-node-profilelifecycle-trace-never-stops-the
Oct 9, 2026
Merged

s1gr1d merged 2 commits into
developfrom
sigridhuemer/js-3893-profiling-node-profilelifecycle-trace-never-stops-the

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

With profileLifecycle: 'trace', the profiler counted every spanStart and spanEnd. Unsampled child spans emit spanStart but never spanEnd, so the count never got back to 0. The profiler kept running, and Node never exited.

  • Trace mode now tracks only sampled spans, by span ID.
  • A stop just before the next 60s chunk started did not prevent that chunk, so profiling started again (manual and trace mode). A stop now cancels the scheduled chunk.
  • New debug logs show skipped unsampled traces and cancelled chunks.

A fake-timer test stops profiling in the gap between two chunks and checks that no new chunk starts.

Fixes #25174

@s1gr1d
s1gr1d requested a review from a team as a code owner October 9, 2026 08:53
@s1gr1d
s1gr1d requested review from andreiborza and mydea and removed request for a team October 9, 2026 08:53
@linear-code

linear-code Bot commented Oct 9, 2026

Copy link
Copy Markdown

JS-3893

@s1gr1d

s1gr1d commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c0cf2d0. Configure here.

A startProfiler() call after the chunk timer stopped a chunk, but before the
scheduled next chunk started, began a new chunk. The scheduled restart then
stopped it almost at once and sent a very short chunk. Start and stop now share
one check that treats this gap as a running session.

Also move the comment that explains the deferred restart to the setImmediate call.

@chargome chargome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!!

@s1gr1d
s1gr1d enabled auto-merge (squash) October 9, 2026 09:15
@s1gr1d
s1gr1d merged commit 84d6378 into develop Oct 9, 2026
59 checks passed
@s1gr1d
s1gr1d deleted the sigridhuemer/js-3893-profiling-node-profilelifecycle-trace-never-stops-the branch October 9, 2026 09:26
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.

profiling-node: profileLifecycle: 'trace' never stops the profiler when spans are unsampled, so Node never exits

2 participants