Skip to content

fix(web): retry transient thread watch failures - #871

Merged
nixuuu merged 1 commit into
devfrom
fix/thread-watch-recovery
Nov 16, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/thread-watch-recovery

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 16, 2026

Copy link
Copy Markdown
Member

Problem

A transient untyped exception from the gateway thread watcher arrived in the web client as Code.Unknown with watch_failed. The client treated it as deterministic data corruption, exhausted reset → smaller → stop, and left the thread requiring a page refresh.

Change

  • classify only Code.Unknown with watch_failed as a transient stream failure;
  • resume the watcher through the existing reconnect backoff;
  • keep decode_error on the bounded cursor repair path;
  • add a regression test and document the recovery behavior.

Validation

  • bun run check:tmp packages/domain/src/thread-watch-liveness.test.ts
  • bun run --filter @canopy/domain typecheck
  • bunx oxlint packages/domain/src/thread-watch-recovery.ts packages/domain/src/thread-watch-liveness.test.ts
  • git diff --check

Copy audit: no user-facing UI text changed.

@nixuuu
nixuuu enabled auto-merge (squash) November 16, 2026 13:12
@nixuuu
nixuuu merged commit 9dabad1 into dev Nov 16, 2026
15 checks passed
@nixuuu
nixuuu deleted the fix/thread-watch-recovery branch November 16, 2026 13:18
nixuuu added a commit that referenced this pull request Nov 17, 2026
## Change

A disconnected thread could repeatedly fail to resume with
`Unknown/watch_failed` while **Load from scratch** restored it. A
snapshot from another reader can leave several pending revisions of the
same large item in the replay range. Saving those revisions in a single
upsert violated PostgreSQL's one-update-per-row rule and rolled back
every resume attempt.

Keep the latest revision per entity when saving current content
pointers, including inline replacements and removals, and prevent older
revisions from overwriting newer pointers. Replay still delivers every
sequence record. After two transient retries, repeated untyped gateway
failures now try a fresh window, then a smaller window, before stopping
with recovery actions. Visible messages remain available during
recovery; ordinary transport drops retain automatic retries.

The regression reproduces the original failure over WorkerLink and gRPC,
then verifies replay catches up without replacing the snapshot. A
separate gRPC-to-SSE regression verifies automatic recovery with a fresh
window. Updated the transcript and UI API documentation.

## Verification

- `check:tmp`: 27 passing tests across thread sequence content replay,
replication retention, watch failures, and watch liveness; no temporary
files left behind.
- Domain and integration package typechecks passed.
- Edited-file lint and formatting passed; `git diff --check` passed.
- Full repository checks and builds remain with CI.
- Copy audit: not applicable; no user-facing text changed.

Fixes: #864
Fixes: #871
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