Fix broker shutdown hang on unresponsive socket#300
Fix broker shutdown hang on unresponsive socket#300dhruvac29 wants to merge 2 commits intoopenai:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 95c05c111b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR prevents SessionEnd from hanging indefinitely by adding a bounded timeout to the broker shutdown RPC and ensuring the shutdown socket is cleaned up via a single guarded completion path.
Changes:
- Add an optional
timeoutMs(default5000) tosendBrokerShutdownand resolve on timeout. - Centralize shutdown completion logic for
data,error,close, and timeout; destroy the socket during cleanup. - Add a regression test for the “accepts connection but never responds” broker behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
plugins/codex/scripts/lib/broker-lifecycle.mjs |
Adds a bounded timeout + guarded cleanup to prevent indefinite shutdown waits. |
tests/broker-lifecycle.test.mjs |
Introduces a regression test for an unresponsive broker shutdown socket. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fixes a SessionEnd hang where
sendBrokerShutdowncould wait indefinitely if the broker accepted the shutdown socket connection but never replied, errored, or closed.This adds a bounded timeout to the shutdown RPC and uses a single guarded cleanup path for
data,error,close, and timeout.Changes
timeoutMs = 5000tosendBrokerShutdownbroker/shutdownbut never respondsTesting
node --test tests/broker-lifecycle.test.mjs npm testFull suite passed locally: 87 passed, 0 failed.
Fixes #288 .