🪲 BUG-#1: Fix RpcClient pending requests leak - #13
Conversation
|
Follow-up commit: the original tests spawned a real |
There was a problem hiding this comment.
🔍 Code Review
Overall this is a solid, well-scoped fix with good test coverage. The ProcessHandle interface abstraction is a clean design that makes the code properly testable without spawning real processes. Two follow-up suggestions below around edge cases in rejectPending.
Code issues found: 2
| # | Severity | Comment |
|---|---|---|
| 1 | [Suggestion] | pending.clear() after resolve() risks dropping re-entrant requests |
| 2 | [Suggestion] | post-exit request() calls hang forever — no dead guard |
…s after the process dies
Description
src/core-client/core-client.ts: ExtractedProcessHandleinterface fromCoreProcessto decoupleRpcClientfrom the concrete process implementation. AddedrejectPending()private method that settles all in-flight requests with a JSON-RPC-32000error. Hooked it intoexitandspawnErrorevent handlers, and replaced the silentpending.clear()indispose().test/core-client.test.ts: Added 4 unit tests using aFakeProcess(lightweight EventEmitter stub) covering: process exit mid-flight, spawn failure, dispose, and normal response resolution.Motivation and Context
Closes #1
RpcClient.request()stored promise resolvers in apendingmap and only resolved them when a matching JSON-RPC response arrived. If the child process exited or failed to spawn, those promises hung forever — callers (sendPrompt,askAside, etc.) would block indefinitely with no way to recover.Types of changes
Checklist