-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: Explicitly exit CLI to prevent hanging subprocesses #3083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 5 commits
bbfca8b
37d011f
b54a8d3
1250deb
7da8a66
c1add61
f971679
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,10 +76,14 @@ export namespace SessionPrompt { | |
|
|
||
| return { | ||
| queued, | ||
| ensureTitlePromise: undefined as Promise<void> | undefined, | ||
|
||
| } | ||
| }, | ||
| async (current) => { | ||
| current.queued.clear() | ||
| log.info("waiting for session title to be generated") | ||
| await current.ensureTitlePromise | ||
| log.info("session title awaited") | ||
| }, | ||
| ) | ||
|
|
||
|
|
@@ -216,7 +220,7 @@ export namespace SessionPrompt { | |
| (messages) => insertReminders({ messages, agent }), | ||
| ) | ||
| if (step === 0) | ||
| ensureTitle({ | ||
| state().ensureTitlePromise = ensureTitle({ | ||
| session, | ||
| history: msgs, | ||
| message: userMsg, | ||
|
|
@@ -1635,7 +1639,7 @@ export namespace SessionPrompt { | |
| thinkingBudget: 0, | ||
| } | ||
| } | ||
| generateText({ | ||
| await generateText({ | ||
| maxOutputTokens: small.info.reasoning ? 1500 : 20, | ||
| providerOptions: { | ||
| [small.providerID]: options, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there any other cases besides the docker mcps?
Can't we just track the pid from transports and send a SIGKILL if they are still running post close?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a shell script wrapping an stdio MCP that has the same behavior. I can send it to you later today. I can imagine there can be other cases where an MCP misbehaves in a similar way. I have seen a few MCP server implementations and the general vibe is not high quality or well thought out.
I would like to avoid using SIGKILL. Fact of the matter is, the actual MCP server process receives SIGTERM when process.exit() is called. I confirmed that by running
straceon the container's PID. But from the POV of OC, the child process is not the MCP server, but rather the docker client managing the MCP server.The PID from the transports is an implementation detail - I would like to avoid using that too.
Any subprocess not under our control can cause the hang. The process.exit is a panacea, and as long as we do proper awaits, it won't cause any issues. Which we do for the most part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shell script + how I use it in
opencode.json, as promised: https://gist.github.com/veracioux/3a9fe2ea06fca0d16852481030d9297e