Description
Two related problems, both in the TUI worker/RPC path and its test coverage.
- Worker bootstrap failure hangs the TUI
#5 fixed early RPC requests being dropped by having the client hold requests
until the worker posts rpc.ready. That closes the drop, but not the hang: if
the worker dies before it reaches Rpc.listen(), rpc.ready never arrives and
every call sits in the client outbox forever. The user sees the same blank
screen #5 set out to fix, just from a different cause.
worker.onerror only logs, and neither the transport setup nor
validateSession has a timeout, so there is no path that ever rejects.
Two smaller issues in the same file:
listen() looks methods up with a bare rpc[method], which resolves through
Object.prototype. A request for toString/constructor invokes it and
replies with a bogus rpc.result instead of an unknown-method error.
- The
queue() comment claims it must be "the first statement" in the worker.
That is not achievable: ESM evaluates imports before the module body, and
worker.ts transitively imports core/global, which has a top-level await, so
execution yields to the event loop before queue() runs. queue() narrows
the window; the rpc.ready handshake is what actually guarantees delivery.
Worth correcting so nobody later relies on queue() for a new pre-ready
message type.
- Unit tests failing in CI
unit (linux) and unit (windows) have both been intermittently red on main,
independent of the above.
-
linux: mcp.McpOAuthCallback > ensureRunning starts a server that isRunning() reflects. The callback server is a module-level singleton and bun shares
module state across test files in one process, so a server left listening by
an earlier file makes the test's opening
expect(isRunning()).toBe(false) fail in ~1ms. The leak is
oauth-auto-connect.test.ts: authenticate() starts the server and the file
never stops it.
-
windows: rotating timeout flakes rather than real bugs. Three red runs hit
three different tests, each a hardcoded per-test budget that a loaded runner
exceeds (e.g. cancel with queued callers resolves all cleanly timing out at
3s, in a file where sibling tests already take 2-8.5s on windows).
Plugins
No response
PhysicsCode version
No response
Steps to reproduce
Worker hang:
- Make the TUI worker fail during bootstrap (e.g. force
Log.init to throw,
or make an XDG directory unwritable so core/global's mkdir fails).
- Run
physicscode tui.
- The TUI sits on a blank screen indefinitely. No error, no timeout.
oauth singleton leak:
- bun test test/mcp/oauth-auto-connect.test.ts
- Observe
McpOAuthCallback.isRunning() is still true afterwards.
- Run any file ordered after it that asserts the server is stopped, e.g.
test/mcp/oauth-callback.test.ts, and its first assertion fails
(Expected: false / Received: true).
Screenshot and/or share link
No response
Operating System
Ubuntu 22.04 + Windows 11 (CI runners)
Terminal
No response
Description
Two related problems, both in the TUI worker/RPC path and its test coverage.
#5 fixed early RPC requests being dropped by having the client hold requests
until the worker posts
rpc.ready. That closes the drop, but not the hang: ifthe worker dies before it reaches
Rpc.listen(),rpc.readynever arrives andevery call sits in the client outbox forever. The user sees the same blank
screen #5 set out to fix, just from a different cause.
worker.onerroronly logs, and neither the transport setup norvalidateSessionhas a timeout, so there is no path that ever rejects.Two smaller issues in the same file:
listen()looks methods up with a barerpc[method], which resolves throughObject.prototype. A request for
toString/constructorinvokes it andreplies with a bogus
rpc.resultinstead of an unknown-method error.queue()comment claims it must be "the first statement" in the worker.That is not achievable: ESM evaluates imports before the module body, and
worker.ts transitively imports
core/global, which has a top-level await, soexecution yields to the event loop before
queue()runs.queue()narrowsthe window; the
rpc.readyhandshake is what actually guarantees delivery.Worth correcting so nobody later relies on
queue()for a new pre-readymessage type.
unit (linux)andunit (windows)have both been intermittently red on main,independent of the above.
linux:
mcp.McpOAuthCallback > ensureRunning starts a server that isRunning() reflects. The callback server is a module-level singleton and bun sharesmodule state across test files in one process, so a server left listening by
an earlier file makes the test's opening
expect(isRunning()).toBe(false)fail in ~1ms. The leak isoauth-auto-connect.test.ts:
authenticate()starts the server and the filenever stops it.
windows: rotating timeout flakes rather than real bugs. Three red runs hit
three different tests, each a hardcoded per-test budget that a loaded runner
exceeds (e.g.
cancel with queued callers resolves all cleanlytiming out at3s, in a file where sibling tests already take 2-8.5s on windows).
Plugins
No response
PhysicsCode version
No response
Steps to reproduce
Worker hang:
Log.initto throw,or make an XDG directory unwritable so core/global's mkdir fails).
physicscode tui.oauth singleton leak:
McpOAuthCallback.isRunning()is still true afterwards.test/mcp/oauth-callback.test.ts, and its first assertion fails
(Expected: false / Received: true).
Screenshot and/or share link
No response
Operating System
Ubuntu 22.04 + Windows 11 (CI runners)
Terminal
No response