Skip to content

fix(core): Store child span timeout handle in _childSpanTimeoutID - #23429

Open
suhailopensource wants to merge 1 commit into
getsentry:developfrom
suhailopensource:fix/idle-span-child-timeout-handle
Open

fix(core): Store child span timeout handle in _childSpanTimeoutID#23429
suhailopensource wants to merge 1 commit into
getsentry:developfrom
suhailopensource:fix/idle-span-child-timeout-handle

Conversation

@suhailopensource

Copy link
Copy Markdown

_restartChildSpanTimeout stored its timer handle in _idleTimeoutID instead of _childSpanTimeoutID, so
_childSpanTimeoutID was never assigned and _cancelChildSpanTimeout() was dead at both of its call sites.

Root cause

On the idleSpanEnableAutoFinish path, _restartIdleTimeout() arms the idle timer and the immediately
following _restartChildSpanTimeout() overwrites its handle without clearing it, orphaning an armed idle timer
that nothing can cancel. When the in-flight children finish, _popActivity's _cancelIdleTimeout() cancels the
child timer instead, and the orphan later fires and ends the idle span at signalTime + idleTimeout rather than
lastChildEnd + idleTimeout. Child spans starting in that window are dropped from the transaction.

The other caller, _pushActivity, is unaffected because _cancelIdleTimeout() already runs immediately before
it — which is why no existing test covered this.

childSpanTimeout itself kept working by accident via _cancelIdleTimeout, so this does not change its
behaviour; it only makes the two timers independent, as the code already intended.

Fixes #23404

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).
  • Link an issue if there is one related to your pull request.

@suhailopensource
suhailopensource marked this pull request as ready for review August 14, 2026 03:46
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.

core: Idle span ends early because _restartChildSpanTimeout writes its handle to _idleTimeoutID

1 participant