📝 Document known has_replay timing gap for non-view RUM events (RUMS-6240) - #4942
Open
c-tshibas wants to merge 1 commit into
Open
📝 Document known has_replay timing gap for non-view RUM events (RUMS-6240)#4942c-tshibas wants to merge 1 commit into
c-tshibas wants to merge 1 commit into
Conversation
…-6240 replay-race issue
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
c-tshibas
commented
Aug 12, 2026
c-tshibas
left a comment
Author
There was a problem hiding this comment.
I have read the CLA Document and I hereby sign the CLA
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
Investigating RUMS-6240, a customer reported that some RUM errors have no
Session Replay recording available (
has_replayunset), including caseswhere a replay segment genuinely exists covering the exact timestamp of the
error. This PR documents the confirmed root cause as a code comment to
anchor a design discussion with the Session Replay team before any behavior
change is proposed -- no behavior change is included here.
Findings (pinpoints)
sessionContext.ts:34-40-- VIEW events compute
has_replayfromgetReplayStats(view.id)(retainedhistory, keyed by view). Every other event type (error/action/resource)
instead takes a live, one-shot read of
recorderApi.isRecording(), with noretry and no history.
recorderApi.ts:46-69--
isRecording()requiresgetDeflateWorkerStatus() === DeflateWorkerStatus.Initialized,which only resolves after the Deflate worker's async
postMessageinithandshake completes. The existing code comment there explicitly documents
that this is an intentional false-negative bias, not an oversight.
datadogRecorder.ts:60-66--
record()(which starts DOM mutation capture and the initial fullsnapshot) is called as soon as
RecorderStatus.Started, which onlyrequires the Deflate
Workerinstance to exist.deflateWorker.ts:61-67--
startDeflateWorker()returns the rawWorkeras soon as its status isLoadingorInitialized-- it does not wait for the init handshake.Put together: local DOM-mutation recording (and the segment that will
eventually cover a given moment) can start strictly before
isRecording()is able to return
true, because the two conditions are gated differently.An error firing in that window gets
has_replay: undefinedbaked inpermanently, since (unlike VIEW events) non-view events are assembled once
with no retroactive re-evaluation.
Existing test already encodes this exact contract:
sessionContext.spec.ts(should set hasReplay when recording has started (isRecording) on events)asserts
getReplayStatsis never called for non-view events, and thathas_replayflips solely based onisRecording()-- confirming this isn'tan accidental oversight but a deliberate (if incompletely reasoned about)
design choice.
Prior related fix was narrower than it might appear:
RUM-7694("Keep more ReplayStats history to avoid wrongly marking views as having
no replay", commit
81193e5d7, PR #3318) only touchedpackages/rum/src/domain/replayStats.ts(MAX_STATS_HISTORYbump) and onlyaffects the VIEW-event branch. It never touched the non-view path described
here.
Concrete evidence (anonymized): reviewing one flagged error's Session
Replay debug metadata showed the error's own timestamp matched the
STARTtimestamp of that view's first replay segment (
has_full_snapshot: true),and that segment's
[start, end]window fully contained the error. Theerror still showed no Session Replay icon. This confirms the gap isn't just
theoretical -- a replay can genuinely exist covering an error's moment while
has_replayis still incorrectly unset for that specific error event.Changes
Adds an explanatory code comment at the non-view branch in
sessionContext.tspinpointing this known gap for future readers/fixers. No behavior change.
A first-pass fix was prototyped (a
hasReplayDataForView()check bypassingthe worker-init gate, backed directly by the existing
replayStats.tsmap)and does close most of the window -- but not all of it: an error firing
before the recorder has captured any record yet (not just before the
worker is initialized) would still read as
has_replay: undefined. Closingthat residual gap likely needs either a short buffering delay before
finalizing a non-view event's
has_replay, or moving the determinationserver-side against the error's timestamp -- both of which seemed like
decisions worth surfacing to the Session Replay team before writing code,
rather than shipping unilaterally. Happy to open a follow-up PR with that
prototype if useful context for the discussion.
Test instructions
N/A -- comment-only change, no behavior affected.
Checklist
Refs: RUMS-6240
🤖 Generated with Claude Code