Repository navigation
fix(git): do not hang when git fetch stalls on a credential prompt - #42639
Conversation
| if (process.platform === 'win32') | ||
| childProcess.spawnSync(`taskkill /pid ${pid} /T /F`, { shell: true, windowsHide: true }); | ||
| else | ||
| process.kill(pid, 'SIGKILL'); |
There was a problem hiding this comment.
I am not quite sure why we don't do -pid here, and special-case line 240 instead. Perhaps worth some blame archeology to understand it.
There was a problem hiding this comment.
kill(-pid) needs a process group leader. launchProcess spawns browsers with detached: true, so the browser leads its own group. Workers are forked with detached: false on purpose (so Ctrl+C reaches them), and spawnAsync children are not detached either, so -pid would throw ESRCH there. Hence the split.
| resolve({ stdout, stderr, code }); | ||
| }); | ||
| child.on('error', error => { | ||
| clearTimeout(timer); |
There was a problem hiding this comment.
Do we need killProcessTree here just in case?
There was a problem hiding this comment.
Not needed. error fires when the spawn failed (no pid), when kill() failed (we never call it), or when an IPC send failed (no channel). Nothing is left running on that path.
Test results for "MCP"8348 passed, 1376 skipped Merge workflow run. |
Test results for "tests 1"8 flaky51415 passed, 1246 skipped Merge workflow run. |
Summary
spawnAsyncnow enforces itstimeoutitself: kills the process tree and resolves withtimedOut, instead of relying on Node's timeout which only kills the direct child and then waits forclosethat never fires while grandchildren hold the stdio pipes.credential.interactive=falseandGIT_TERMINAL_PROMPT=0so a fetch without credentials fails fast instead of prompting.killProcessTreeintoprocessLauncher.tsand mergedspawnAsyncinto it.Fixes #42630