Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions agents/src/ipc/supervised_proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ export abstract class SupervisedProc {
}
this.#closing = true;

if (!this.init.done) {
this.init.reject(new Error('process closed before initialization completed'));
this.proc?.kill();
await this.#join.await.then(() => {
this.clearTimers();
});
return;
Comment on lines +232 to +238

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 initialize() caller may hang when close() is called during initialization

The new close() path correctly rejects init and resolves #join, fixing the issue where close() itself would hang. However, if a caller (e.g. proc_pool.ts:108-109 in procWatchTask) is concurrently awaiting proc.initialize(), that call hangs forever on once(this.proc!, 'message') at supervised_proc.ts:217 because killing a child process emits 'exit'/'close' but NOT 'error', so events.once() never resolves or rejects. This is a pre-existing issue not introduced by this PR — in fact, the old code was worse because close() itself would also hang. The fix here is a meaningful improvement, but a complete solution would also need initialize() to detect the killed process (e.g., by racing once(proc, 'message') with once(proc, 'exit') or using an AbortSignal).

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

}

if (this.proc?.connected) {
this.proc.send({ case: 'shutdownRequest' });
}
Expand Down