fix(sdk): ensure opencode server closes cleanly via process groups#21626
fix(sdk): ensure opencode server closes cleanly via process groups#21626sigmaSd wants to merge 2 commits intoanomalyco:devfrom
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, here are related PRs that address similar process cleanup issues: Potentially Related PRs:
These PRs all address related concerns around process cleanup, orphaned processes, and server shutdown—though none appear to be exact duplicates of PR #21626. Your PR takes a specific approach using process groups and detached spawning for the SDK's opencode server management. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #21628
Type of change
What does this PR do?
This PR fixes an issue where calling server.close() would only terminate the immediate process wrapper, leaving the underlying opencode server orphaned and the network port occupied.
I updated the SDK to spawn the process in a new process group (detached: true). This change uses a negative PID (-proc.pid) on POSIX systems to signal the entire process group. In windows this seems already handled via taskkill /T /F .
The use case I have opencode installed with deno, when I use the close api it kills the deno wrapper but not the actual opencode binary, this fixes it.
If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!
How did you verify your code works?
With this change close kills deno wraooer and opencode
Checklist