🐛 Align session-ended WebSocket teardown with the latest view's end clocks - #4911
Open
bdibon wants to merge 4 commits into
Open
🐛 Align session-ended WebSocket teardown with the latest view's end clocks#4911bdibon wants to merge 4 commits into
bdibon wants to merge 4 commits into
Conversation
Expose the exact end clocks of the latest ended view so that session-expiry teardown code can reuse them instead of racing an independently computed clocksNow().
…locks Session-expiry teardown flushed open WebSocket connections using clocksNow(), which could land a few milliseconds after the ended view's own end clocks. Passing viewHistory.getLatestViewEndClocks() into flushOpenConnections keeps the session-ended completed event and the websocket-closed vital aligned with the view boundary.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bundles Sizes Evolution
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 700d262 | Docs | Datadog PR Page | Give us feedback! |
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.
Motivation
When a RUM session expires, open WebSocket connections are finalized with
tracking_end_reason: 'session_end'. Until now the teardown usedclocksNow()as the end time. Because the active view is ended before the SDK reaches the session-boundary cleanup,clocksNow()lands slightly after the view'send_time— so the resultingwebsocket-closedvital was dropped during assembly and the resource'send_timefell outside the lifespan of the view it was attached to.Changes
ViewHistory.getLatestViewEndClocks(), returning the end clocks of the most recently ended view (reset onSESSION_RENEWED), documented with its intended session-boundary use.SESSION_EXPIRED, thread those end clocks intoflushOpenConnectionsso thewebsocket-closedvitalstartClocks, the resourceend_time, andend_view_idall stay within the ending view's window.flushOpenConnectionsstill falls back toclocksNow()when no end clocks are available (e.g. the collection's ownstop()).websocket-closedvital and resourceend_timedo not exceed the associated view's end time.Ordering note: this relies on
trackViews'SESSION_EXPIREDsubscriber (registered first) ending the view and notifyingAFTER_VIEW_ENDEDsynchronously beforewebSocketCollection's subscriber readsgetLatestViewEndClocks().Test instructions
Checklist
🤖 Generated with Claude Code