Skip to content

fix: settle rpc calls when postMessage throws instead of leaking them (#397) - #446

Merged
agenteinstinct1-max merged 2 commits into
dev-vibecodedfrom
fix/rpc-postmessage-throw
Oct 21, 2026
Merged

agenteinstinct1-max merged 2 commits into
dev-vibecodedfrom
fix/rpc-postmessage-throw

Conversation

@agenteinstinct1-max

Copy link
Copy Markdown
Collaborator

Closes #397.

Rpc.client.call() registered the pending promise and then called target.postMessage(...) unguarded. The worker targets throw synchronously when the worker is terminated or in its crash-restart window (WorkerPostMessageTarget: if (!current) throw), so the pending entry was never removed nor rejected, and target.onclose only fires on actual process exit - the caller hung forever (headless run awaiting background.wait, TUI createWorkerFetch looking like a freeze).

call() now wraps postMessage in try/catch: on a synchronous throw it deletes the pending entry and rejects with the original error, so the failure surfaces at the call site immediately and the pending map does not grow.

Tests: new case covers the throw path (rejects with the worker error) and verifies the entry is gone (a later call, once the target recovers, resolves normally). Full test/util suite 131 pass / 0 fail.

@github-actions

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@kilo-code-bot

kilo-code-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • packages/llm/src/protocols/openai-responses.ts
  • packages/llm/src/route/client.ts
  • packages/llm/test/provider/openai-responses.test.ts
  • packages/opencode/src/util/rpc.ts
  • packages/opencode/test/util/rpc.test.ts

Reviewed by free · Input: 43.5K · Output: 1.8K · Cached: 161.7K

@agenteinstinct1-max
agenteinstinct1-max merged commit b3a1300 into dev-vibecoded Oct 21, 2026
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant