Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(replay): let users retry a failed recording in place (#82971)

posthog[bot]aa7b182ea2f5
diff --git a/frontend/src/scenes/session-recordings/player/PlayerFrameOverlay.tsx b/frontend/src/scenes/session-recordings/player/PlayerFrameOverlay.tsx
index c9ba03d0cad8..b7c4acd7bf44 100644
--- a/frontend/src/scenes/session-recordings/player/PlayerFrameOverlay.tsx
+++ b/frontend/src/scenes/session-recordings/player/PlayerFrameOverlay.tsx
@@ -69,10 +69,18 @@ const PlayerFrameOverlayActions = (): JSX.Element | null => {
)
}
+// Failures that a fresh load attempt can fix (a snapshot API or blob fetch that failed in transit),
+// as opposed to a recording whose data is genuinely unplayable.
+const RECOVERABLE_SNAPSHOT_ERRORS = [
+ 'loadSnapshotsForSourceFailure',
+ 'loadSnapshotSourcesFailure',
+ 'snapshotSourceLoadExhausted',
+]
+
const PlayerFrameOverlayContent = (): JSX.Element | null => {
const { currentPlayerState, endReached, logicProps, playerError, isWaitingForIngestion } =
useValues(sessionRecordingPlayerLogic)
- const { setPlay } = useActions(sessionRecordingPlayerLogic)
+ const { setPlay, retryLoadingSnapshots } = useActions(sessionRecordingPlayerLogic)
const handlePlay = (e: MouseEvent): void => {
e.stopPropagation()
@@ -89,23 +97,41 @@ const PlayerFrameOverlayContent = (): JSX.Element | null => {
if (currentPlayerState === SessionPlayerState.ERROR) {
const isMissingFullSnapshot = playerError === 'noPlayableFullSnapshot'
const isUnauthorized = playerError === 'snapshotUnauthorized'
+ const isRecoverable = !!playerError && RECOVERABLE_SNAPSHOT_ERRORS.includes(playerError)
content = (
<div className="flex flex-col justify-center items-center p-6 bg-surface-primary rounded m-6 gap-2 max-w-120 shadow-sm">
<IconWarning className="text-danger text-5xl" />
- <div className="font-bold text-text-3000 text-lg">We're unable to play this recording</div>
+ <div className="font-bold text-text-3000 text-lg">
+ {isRecoverable ? "We couldn't load this recording" : "We're unable to play this recording"}
+ </div>
<div className="text-secondary text-sm text-center">
{isMissingFullSnapshot
? 'This part of the recording is missing the snapshot data needed to render it. The data never reached PostHog, usually because the browser was closed or went offline before the recording finished uploading.'
: isUnauthorized
? 'Your session has expired. Sign in again to keep watching this recording.'
- : 'An error occurred that is preventing this recording from being played. You can refresh the page to reload the recording.'}
+ : isRecoverable
+ ? "We couldn't fetch the recording data. This is usually a temporary network problem. Retry, and if it keeps failing contact support."
+ : 'An error occurred that is preventing this recording from being played. You can refresh the page to reload the recording.'}
</div>
{isUnauthorized && (
<LemonButton to={urls.login()} type="primary" fullWidth center>
Sign in
</LemonButton>
)}
- {!isMissingFullSnapshot && !isUnauthorized && (
+ {isRecoverable && (
+ <LemonButton
+ onClick={(e) => {
+ e.stopPropagation()
+ retryLoadingSnapshots()
+ }}
+ type="primary"
+ fullWidth
+ center
+ >
+ Retry
+ </LemonButton>
+ )}
+ {!isMissingFullSnapshot && !isUnauthorized && !isRecoverable && (
<LemonButton
onClick={() => {
window.location.reload()
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
index bf2d43bff845..9016f023e103 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
@@ -730,6 +730,9 @@ export interface sessionRecordingPlayerLogicActions {
error: string
errorObject?: any
} // snapshotDataLogic
+ retrySnapshotLoading: () => {
+ value: true
+ } // snapshotDataLogic
setPlayerActive: (active: boolean) => {
active: boolean
} // snapshotDataLogic
@@ -845,6 +848,9 @@ export interface sessionRecordingPlayerLogicActions {
restartIframePlayback: () => {
value: true
}
+ retryLoadingSnapshots: () => {
+ value: true
+ }
schedulePlayerTimeTracking: () => {
value: true
}
@@ -1165,6 +1171,7 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
'loadSnapshotsForSourceFailure',
'loadSnapshotSourcesFailure',
'snapshotSourceLoadExhausted',
+ 'retrySnapshotLoading',
'loadNextSnapshotSource',
'loadAllSources',
'setTargetTimestamp',
@@ -1195,6 +1202,7 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
endScrub: true,
setPlayerError: (reason: string) => ({ reason }),
clearPlayerError: true,
+ retryLoadingSnapshots: true,
setSkippingInactivity: (isSkippingInactivity: boolean) => ({ isSkippingInactivity }),
setSkippingToMatchingEvent: (isSkippingToMatchingEvent: boolean) => ({ isSkippingToMatchingEvent }),
syncPlayerSpeed: true,
@@ -2568,6 +2576,10 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
console.error('PostHog Recording Playback Error: Snapshot processing repeatedly failed')
actions.setPlayerError('snapshotProcessingFailed')
},
+ retryLoadingSnapshots: () => {
+ actions.clearPlayerError()
+ actions.retrySnapshotLoading()
+ },
setPlay: () => {
if (!values.snapshotsLoaded) {
actions.loadSnapshots()
diff --git a/frontend/src/scenes/session-recordings/player/snapshotDataLogic.test.ts b/frontend/src/scenes/session-recordings/player/snapshotDataLogic.test.ts
index 02521cf24eac..880d82e60dab 100644
--- a/frontend/src/scenes/session-recordings/player/snapshotDataLogic.test.ts
+++ b/frontend/src/scenes/session-recordings/player/snapshotDataLogic.test.ts
@@ -85,6 +85,25 @@ describe('snapshotDataLogic', () => {
consoleError.mockRestore()
})
+ it('re-arms the retry budget after retrySnapshotLoading, so a later failure is not instantly exhausted', async () => {
+ const consoleError = jest.spyOn(console, 'error').mockImplementation(() => {})
+ // Exhaust the budget; consume the terminal action so it is out of the recording window.
+ await expectLogic(logic, () => {
+ logic.actions.loadSnapshotsForSourceFailure('load failed', new Error('load failed'))
+ logic.actions.loadSnapshotsForSourceFailure('load failed', new Error('load failed'))
+ logic.actions.loadSnapshotsForSourceFailure('load failed', new Error('load failed'))
+ logic.actions.loadSnapshotsForSourceFailure('load failed', new Error('load failed'))
+ }).toDispatchActions(['snapshotSourceLoadExhausted'])
+
+ logic.actions.retrySnapshotLoading()
+
+ // A single failure now must not re-trigger the terminal action — the budget was reset.
+ await expectLogic(logic, () => {
+ logic.actions.loadSnapshotsForSourceFailure('load failed', new Error('load failed'))
+ }).toNotHaveDispatchedActions(['snapshotSourceLoadExhausted'])
+ consoleError.mockRestore()
+ })
+
it('does not grant a permanently-unauthorized source a fresh retry budget on a new seek target', async () => {
const consoleError = jest.spyOn(console, 'error').mockImplementation(() => {})
const error = new ApiError('Unauthorized', 401)
diff --git a/frontend/src/scenes/session-recordings/player/snapshotDataLogic.tsx b/frontend/src/scenes/session-recordings/player/snapshotDataLogic.tsx
index 961c46f5e95f..48da89349f61 100644
--- a/frontend/src/scenes/session-recordings/player/snapshotDataLogic.tsx
+++ b/frontend/src/scenes/session-recordings/player/snapshotDataLogic.tsx
@@ -152,6 +152,9 @@ export interface snapshotDataLogicActions {
resetPollingInterval: () => {
value: true
}
+ retrySnapshotLoading: () => {
+ value: true
+ }
setPlayerActive: (active: boolean) => {
active: boolean
}
@@ -250,6 +253,9 @@ export const snapshotDataLogic = kea<snapshotDataLogicType>([
// per-attempt loadSnapshotsForSourceFailure so the player can show an error even when other
// sources already loaded (otherwise seeks into the missing range buffer forever).
snapshotSourceLoadExhausted: true,
+ // Re-arm loading after a terminal failure: clears the exhausted retry budget and restarts the
+ // load chain, so the user can recover from a transient fetch failure without reloading the page.
+ retrySnapshotLoading: true,
loadSnapshotSources: (breakpointLength?: number) => ({ breakpointLength }),
loadNextSnapshotSource: true,
loadSnapshotsForSource: (sources: Pick<SessionRecordingSnapshotSource, 'source' | 'blob_key'>[]) => ({
@@ -495,6 +501,15 @@ export const snapshotDataLogic = kea<snapshotDataLogicType>([
}
},
+ retrySnapshotLoading: () => {
+ // The failure count is what tips a source into snapshotSourceLoadExhausted, so reset it
+ // before restarting — otherwise the very next attempt is already over the cap.
+ cache.loadFailureCount = 0
+ // Re-fetch the source list, which on success re-triggers loadNextSnapshotSource. This
+ // recovers both a failed source listing and a failed per-source fetch.
+ actions.loadSnapshots()
+ },
+
loadSnapshotSourcesSuccess: ({ snapshotSources }) => {
const currentSourceKeys = snapshotSources
.map((s) => s.blob_key)