Repository navigation
fix(opencode): wait for the TUI worker to listen before sending RPC calls - #55950
shunkakinoki wants to merge 1 commit into
Conversation
…alls Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The following comment was made by an LLM, it may be inaccurate: |
|
AI-assisted supplemental Windows verification of With Git-blob-verified copies of the actual dependency-free RPC module, the unchanged new upstream regression plus four independent real-Worker tests give 5 passes on head versus 2 passes / 3 timeouts on base. The additional cases cover queued calls with out-of-order responses, separate delayed workers, post-listen JSON values (including CJK/emoji), and event delivery/unsubscribe. This validates the protocol repair on native Windows with simulated module-evaluation delay. It does not measure shipped TUI startup, fleet failure rates, Bun 1.4.3, full-package tests or types. The source review includes the TUI's immediate client attachment and the worker's final reviewed and tested locally. |
|
Closing: this race lives in the 1.x TUI's Worker + |
Issue for this PR
Closes #55949
Type of change
What does this PR do?
The TUI sends its first RPC calls (
fetch, thencheckUpgrade) to the server worker as soon as the worker is created. The worker only setsonmessageinRpc.listen(rpc), on its last line, after its module evaluation finishes, including the top-levelawaitincore/src/global.ts. Bun drops messages that arrive at a worker during that window, andcall()never rejects, so the TUI waits forever and never draws.Fix, all in
util/rpc.ts:listen()postsrpc.readyright after settingonmessage.client()holds every request until it seesrpc.ready.Nothing else changes. Worker-to-main events were never affected, because the main thread sets its handler synchronously after
new Worker.How did you verify your code works?
test/util/rpc.test.ts: a fixture worker emitsstarted, then sits in a top-level await before callingRpc.listen. The test calls into it during that await. Without the fix it times out; with it, it passes.creating instancelog line, database never opened.bun run typecheckinpackages/opencodepasses.Screenshots / recordings
Not a UI change.
Checklist
🤖 Generated with Claude Code