8000 A stalled provider call holds the mutation lock for the whole Library by kiran-brahma · Pull Request #76 · kiran-brahma/writing-tool · GitHub
[go: up one dir, main page]

Skip to content

A stalled provider call holds the mutation lock for the whole Library - #76

Merged
kiran-brahma merged 1 commit into
v1.3from
v1.3-46
Sep 26, 2026
Merged

kiran-brahma merged 1 commit into
v1.3from
v1.3-46

Conversation

@kiran-brahma
Copy link
Copy Markdown
Owner

Closes #46.

What changed

  • src/wire/transport.ts: each attempt now runs under a deadline (requestTimeoutMs, default 5 minutes). The deadline covers the fetch and the body read, is combined with the caller's signal, and starts inside the concurrency gate, so time spent queued does not count. A stall fails with a new TimedOutError: "The X Connection did not respond within 5 minutes. Try again, or check that the Provider is up." It is not retried. The timer is a plain setTimeout that is cleared when the attempt settles, and the promise is raced against the abort, so a request that ignores its signal still ends.
  • src/core/reader.ts / src/storage/readerAccounts.ts: Reader Runs accept a signal and pass it to the Transport. Before this, readSection sent no signal at all.
  • src/runs/useRuns.ts: Reader and Audit Runs each get an AbortController. cancelRun aborts them along with the model-pass controller. A cancelled Reader or Audit Run shows "Run cancelled."
  • The queue ordering is unchanged: a Run still never interleaves with a status write.

Acceptance criteria

  • fetchWithRetry has a request timeout combined with the caller's signal, surfaced as a readable error rather than a hang. Verified by transport.test.ts › "request timeout (A stalled provider call holds the mutation lock for the whole Library #46)", which covers a stalled request, a request that ignores its signal, a body that stalls mid-stream, a cancel that is still reported as a cancel, a Connection test, and the timer being cleared.
  • A cancel signal is threaded through Reader and Audit Runs. Verified by new storage tests: an aborted Reader or Audit Run stores nothing, and a mutation queued behind it (clearReaderAccounts / clearAuditAccounts) then goes through.
  • Test through the send(ModelRequest) seam that a Provider which never responds fails with a timeout rather than blocking. Verified.
  • "Cancel run" stopping a stalled Reader or Audit Run in the running app: not verified here. I did not drive the app against a stalling Provider in a browser. It is covered only by the storage tests and by reading the code.

pnpm test (1005 passed), pnpm typecheck, pnpm run gates and pnpm build all pass. No Dexie migration, no findings-schema change, no new affordance, no DOM test layer.

Open question

The issue gives no timeout value. I chose 5 minutes so that a slow reasoning model on a long Document is not cut off. It is one constant (DEFAULT_REQUEST_TIMEOUT_MS) if you want a different value.

🤖 Generated with Claude Code


Generated by Claude Code

A Run holds the single mutation lock while it awaits the Provider, and the
fetch Transport set no timeout, so a Provider that accepted the connection
and then stalled blocked every later status write, rule run and import.

- The fetch Transport now gives each attempt a deadline (default 5 minutes)
  covering both the request and the body read, combined with the caller's
  signal. A stall fails with a readable TimedOutError and is not retried.
- Reader Runs forward the Run's signal to the Transport, and useRuns gives
  Reader and Audit Runs their own controllers, so Cancel run reaches them.
- Tests through the send seam for a Provider that never responds, one that
  ignores its signal, and one that stalls mid-body; storage tests that an
  aborted Reader or Audit Run stores nothing and frees the queue.

The queue ordering is unchanged: a Run still never interleaves with a
status write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FjB3Gu8vhg5enkAneTdqga
@chatgpt-codex-connector
chatgpt-codex-connector Bot commented Sep 26, 2026 •
Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-26T09:37:38.165158Z 915ee15 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

2 participants

0