Repository navigation
fix(cloudflare): Don't hold Durable Object invocations open with the segment-end flush timer - #25490
Open
philipatkinson wants to merge 1 commit into
Open
philipatkinson wants to merge 1 commit into
philipatkinson wants to merge 1 commit into
Conversation
…segment-end flush timer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
philipatkinson
marked this pull request as ready for review
October 18, 2026 14:50
philipatkinson
requested review from
JPeer264 and
mydea
and removed request for
a team
October 18, 2026 14:50
This branch has not been deployed
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.
Since span streaming became the default (#22642) and segment-end flushing turned on for server runtimes (#23714), every root span end schedules
setTimeout(flush, 500), sampled or not. #23714 relies onsafeUnrefto stop that timer holding a server open, but workerd timers have nounref(). A Durable Object invocation stays open until its pending timers fire, so every instrumented DOfetch, alarm,webSocketMessageand propagated RPC call runs about 500 ms longer. That time is billed as duration, and the pending timer also blocks hibernation. This happens attracesSampleRate: 0too.The 500 ms delay comes from the browser (#19643):
http.clientspans stay open up to 300 ms waiting for resource timing, so they can end after their segment. Neither that nor the buffer-memory reason for flushing at segment end on servers (#23714) applies to Workers, where nothing waits for resource timing and spans are flushed at the end of every invocation.The Cloudflare client now registers
spanStreamingIntegration({ flushOnSegmentEnd: false })unless the user supplies their own. The runtime doesn't need the timer: the boundary flush inwrapMethodWithSentryruns after the method span ends, and the cached client's eager drain covers spans that end after the flush point. This matches the existing_flushInterval: 0for the log and metric buffers. Plain Worker handlers lose the timer too: it doesn't hold their requests open, so it cost them nothing, butwithSentry's boundary flush already delivers their spans. In workerd, with the same change applied to 11.6.0, DOfetchand alarm wall time drops from about 505 ms to about 6 ms, and attracesSampleRate: 1.0the same span envelopes still arrive.Fixes #25489