Skip to content

fix(session): retry session init once, report failure instead of going silent - #1

Open
lgomezt wants to merge 1 commit into
mainfrom
fix/session-init-silent-failure
Open

fix(session): retry session init once, report failure instead of going silent#1
lgomezt wants to merge 1 commit into
mainfrom
fix/session-init-silent-failure

Conversation

@lgomezt

@lgomezt lgomezt commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes the root cause of the 2026-08-07 data-loss incident (pid 54, lab study): initializeSession() swallowed its own failure with console.error only, returned session: null, and never retried — every subsequent activity_logs save then silently no-op'd on the null session for the rest of the visit, invisibly (only study_events, a separate ungated logger, kept working).
  • Both initializeSession() and startFreshSession() (same bug shape) now retry once after 1.5s via a small, unit-tested retryOnce() helper, and on a final failure report it through the app's existing-but-previously-unwired reportLogFailure endpoint — so a recurrence lands in the backend logs the moment it happens instead of requiring a manual activity_logs audit.
  • Full root-cause writeup: analysis/ASSUMPTIONS.md §G5 (private research repo, not in this PR).

⚠️ Deploy note

Merging this to main triggers the Dokploy auto-deploy of the live app (per CLAUDE.md) — the lab study is actively recruiting, so please pick the merge timing deliberately (e.g. not mid-session for an enrolled participant).

Test plan

  • frontend/src/utils/retryOnce.test.ts — 5 new tests: clean first attempt, recovers on retry (the "no data lost" case), retry actually waits delayMs, reports + falls back safely after two failures, onFinalFailure never double-fires.
  • npx tsc -b --noEmit — clean
  • npx vitest run — 60/60 passing (was 55; +5 new)
  • npm run build (full production build) — clean
  • npx eslint on touched files — no new errors (7 pre-existing no-explicit-any errors elsewhere in the file, untouched by this change)

Claude-Session: https://claude.ai/code/session_01QdvEMCZypQR8SePXJiY22C

…of going silent

initializeSession() and startFreshSession() caught their own errors with a
console.error and returned session: null — no retry, no server-side trace.
Every subsequent activity_logs save then no-ops on the null session check,
invisibly. This is what happened to pid 54 on 2026-08-07: a session-init
call failed once during the prepare->teach transition and the rest of their
teach phase (code, oracle, chat, knowledge updates) was never logged, with
no visible error to the participant or a researcher watching live.

Both call sites now retry once after a short delay via a small, tested
retryOnce() helper, and report a final failure through the existing (but
previously unwired) reportLogFailure endpoint, so a recurrence shows up in
the backend logs immediately instead of requiring a manual activity_logs
audit days later.

Claude-Session: https://claude.ai/code/session_01QdvEMCZypQR8SePXJiY22C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant