fix(replay): reset the idle clock before a rotation restart - #4788
Open
fasyy612 wants to merge 2 commits into
Open
fix(replay): reset the idle clock before a rotation restart#4788fasyy612 wants to merge 2 commits into
fasyy612 wants to merge 2 commits into
Conversation
fasyy612
requested review from
TueHaulund,
arnohillen and
ksvat
and removed request for
a team
September 4, 2026 15:22
Contributor
Replay incident risk checkThis diff touches code involved in past incidents. This is a heads-up, not a verdict: read the matched sections of INCIDENTS.md and answer their review questions before merging. For a judgment on whether this diff has the same failure mode, run the |
Contributor
Contributor
posthog-js Compliance ReportDate: 2026-09-04 15:36:27 UTC ✅ All Tests Passed!26/26 tests passed Capture Tests✅ 26/26 tests passed View Details
|
Contributor
|
Size Change: +173 B (0%) Total Size: 20.5 MB 📦 View Changed
ℹ️ View Unchanged
|
marandaneto
approved these changes
Sep 5, 2026
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.
Problem
When a session rotates, the recorder restarts rrweb from inside an rrweb emit. rrweb emits Meta and FullSnapshot synchronously inside
record(), but the last-activity timestamp was only reset afterrecord()returned. So the restart's own snapshots got compared against the previous session's last activity, which can be hours old. We decided the new session was already idle, emitted a sessionIdle marker pinned to it, restamped that marker into the past, and dropped the snapshots.The recording then starts before its own session id was created, with nothing playable until the next user interaction.
This only fires when the rotation comes through the session-manager callback, i.e. an analytics capture after the tab sat idle past the session timeout. The rrweb interactive path was never affected, because it refreshes the timestamp before the session check.
Changes
Reset the last-activity timestamp at the top of
_restartForSessionIdChange, beforestop(). Both rotation paths funnel through that function, so everything emitted during the restart is judged against the new epoch.Tests
Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted) — or — Fully autonomous