fix(windows): resolve past .cmd wrapper to kill opencode.exe process … - #1771
Merged
Conversation
…tree
On Windows, findExecutable('opencode') resolves to a .cmd wrapper that
causes spawnProcess to use shell:true, inserting cmd.exe between the
worker and opencode.exe. This breaks taskkill /T /F's ability to
traverse the process tree, leaving orphaned opencode.exe processes.
Resolve past the .cmd wrapper to the real opencode.exe binary so it
spawns as a direct child. Try both global npm and local/pnpm layouts.
7 tasks
Contributor
…ager.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Contributor
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
…tree
On Windows, findExecutable('opencode') resolves to a .cmd wrapper that
causes spawnProcess to use shell:true, inserting cmd.exe between the
worker and opencode.exe. This breaks taskkill /T /F's ability to
traverse the process tree, leaving orphaned opencode.exe processes.
Resolve past the .cmd wrapper to the real opencode.exe binary so it
spawns as a direct child. Try both global npm and local/pnpm layouts.
Log a warning when neither candidate resolves so the silent fallback
is diagnosable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recreated from: #1328
Linked issue
N/A
Type of change
What does this PR do
On Windows, closing the Paseo desktop app left orphaned `opencode.exe` and `conhost.exe` processes running.
Root Cause
`findExecutable("opencode")` resolves to the npm `.cmd` wrapper (`%APPDATA%\npm\opencode.cmd`). When `spawnProcess` detects a `.cmd` extension, it sets `shell: true`, creating the process tree: `worker → cmd.exe → opencode.exe`. The `cmd.exe` intermediary breaks the parent-child relationship, so `taskkill /T /F` can't traverse to `opencode.exe`, leaving it (and its `conhost.exe`) orphaned.
Fix
Added `resolveWindowsExecutablePath()` in `server-manager.ts` that, on Windows, resolves past `.cmd` wrappers to the actual `opencode.exe` binary at `
/node_modules/opencode-ai/bin/opencode.exe`. This keeps `opencode.exe` as a direct child of the worker, so `taskkill /T /F` properly kills the entire process tree on exit.Changes
How did you verify it
Tested build in Windows, now opencode.exe is properly closed upon Paseo daemon shutdown.
Checklist
npm run typecheckpassesnpm run lintpasses