8000 fix(cli): retry idempotent reports when the pipe is busy by Mattheinrichs · Pull Request #445 · amirlehmam/wmux · GitHub
[go: up one dir, main page]

Skip to content

fix(cli): retry idempotent reports when the pipe is busy - #445

Merged
amirlehmam merged 2 commits into
amirlehmam:masterfrom
Mattheinrichs:fix/cli-report-retry
Nov 7, 2026
Merged

amirlehmam merged 2 commits into
amirlehmam:masterfrom
Mattheinrichs:fix/cli-report-retry

Conversation

@Mattheinrichs
Copy link
Copy Markdown
Contributor

Problem

During a restore burst, wmux's named pipe can answer:

open //./pipe/wmux: All pipe instances are busy

On WSL, npiperelay writes that to stderr and exits before attaching. The OpenCode plugins now retry their own session reports, but every other one-shot producer (report-agent, hook, release-agent) could still lose its only attempt.

Fix

  • Extract the Codex launcher's patience policy into src/cli/transport-retry.ts.
  • Fold npiperelay's stderr into the stream error, so the busy case is recognisable.
  • Use a short retry only for idempotent report verbs:
    report-session, report-agent, report-metadata, report-subagent, release-agent, and prompt admission (hook).
  • A spawn or a typed key never takes this path, so a retry cannot duplicate real work.
  • Ship transport-retry.js with the CLI in extraResources; the resource copies are rebuilt and verify-resources passes.

The retry budget is deliberately short (4 s for reports, 1.5 s for prompt admission). A successful reply resolves immediately; only a request that never produced a response is asked again.

Verification

  • New integration test runs the shipped resources/cli/wmux.js against a socket that drops the first connection: the report retries, lands on the second, and exits 0.
  • New unit tests cover transient vs permanent errors, the budget, and the growing attempt timeout; the Codex launcher's existing patience tests still pass through the shared helper.
  • Targeted suites: 90 passed.
  • npm run typecheck, changed-file lint, and verify-resources: clean.
  • Full WSL suite: 6285 passed, 42 known Windows-path/platform failures — same baseline, none in the changed suites.

Scope

This is PR B. PR A (server-half hardening) is #444; the TUI-half retry is #443. Together they cover the TUI half, the server half, and the CLI transport.

Mattheinrichs and others added 2 commits November 7, 2026 02:09
The named pipe answers "All pipe instances are busy" during a restore burst, and npiperelay reports that on stderr before exiting. The OpenCode plugins now retry their own session reports, but report-agent, hook and release calls from other producers could still lose their one attempt.

Extract the Codex launcher's patience policy into transport-retry.ts, fold npiperelay's stderr into the error so the busy case is recognisable, and use a short retry for the idempotent report verbs only: report-session, report-agent, report-metadata, report-subagent, release-agent and prompt admission. A spawn or a typed key never takes that path, so a retry cannot duplicate real work. The new module ships with the CLI in extraResources.

Verified against the shipped resources/cli/wmux.js with a socket that drops the first connection: the report retried and landed. Targeted suites 90 passed; full WSL suite 6285 passed, 42 known Windows-path/platform failures (none in the changed suites).
A Unix socket path in the temp dir fails with EACCES on Windows, which
is where the release CI runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@amirlehmam
amirlehmam force-pushed the fix/cli-report-retry branch from a09626a to 03098c6 Compare November 7, 2026 01:09
@amirlehmam
amirlehmam merged commit 01f538d into amirlehmam:master Nov 7, 2026
@amirlehmam
Copy link
Copy Markdown
Owner

Merged, thanks! Two things I did on your branch before merging:

I also checked that a replayed hook --prompt cannot double a prompt mark: the renderer dedupes identical agent prompts within 1.5 s, and that covers the 1.5 s prompt budget. This ships in 2.59.0.

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