Conversation
|
The following comment was made by an LLM, it may be inaccurate: Potential related PRs found:
Why they're related: Both PRs address process completion signaling (exit vs. close events) to prevent subprocess hangs, particularly with detached processes. PR #29831 specifically mentions "Windows detached-child hang" which is the same class of issue as what PR #42756 is fixing. |
Scope: the spawner's completion deferred now resolves on whichever of
|
|
I need this fix, so how can I patch my current install with this? |
@goedzo help me to thumb up this PR so it can be merged sooner |
|
@thdxr @rekram1-node Could we have this thin PR be merged, or get any feedback on this? It can close a lot of similar pending issues with only 7+3- lines of prod code changes |
I've actually tested this patch manually, and now at least opencode does no longer hangs on a shell. I tested it like this: call node -e "const fs=require('fs'),path=require('path');function walk(d){let r=[];if(fs.existsSync(d)===false)return r;fs.readdirSync(d).forEach(f=>{let p=path.join(d,f);if(fs.statSync(p).isDirectory()){if((f==='.git')===false)r=r.concat(walk(p));}else if(/.(js|mjs|cjs)$/.test(f))r.push(p);});return r;}walk('node_modules/opencode-ai').forEach(f=>{let c=fs.readFileSync(f,'utf8');if(c.indexOf('proc.on("close"')>=0 || c.indexOf('proc.on(\x27close\x27')>=0){fs.writeFileSync(f,c.replace(/proc.on(\s*[\x22\x27]close[\x22\x27]/g,'proc.on(\x22exit\x22'),'utf8');console.log('[SUCCESS] Patched OpenCode Bash Exit in:',path.basename(f));}});" |
|
@goedzo May you test this too: because at my side, the latest opencode version still hang after showing result "done" |
…eout Verified on opencode 1.18.30: 120s default timeout kills the orphaned-stdio hang tree. Upstream fix pending: anomalyco/opencode#42756.
Issue for this PR
Closes #20902
Closes #25038
Closes #28697
Closes #36342
Closes #37838
Closes #42044
Closes #42524
Type of change
What does this PR do?
Process
exitshould work same as stdiocloseso either one can finish the bash command.How did you verify your code works?
Automated tests:
Manual:
cd packages/opencode && bun dev, then run:node -e 'const {spawn}=require("node:child_process");const c=spawn("sleep",["3600"],{stdio:"inherit",detached:true});c.unref();console.log("done")'Before: see
done, but opencode hang and tool never completes.After: tool returns immediately.
Screenshots / recordings
N/A
Checklist