Skip to content

Commit 50f1a85

Browse files
committed
Fixes early termination issues on other OSs
1 parent 37fc894 commit 50f1a85

File tree

3 files changed

+413
-369
lines changed

3 files changed

+413
-369
lines changed

src/env/node/git/git.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -427,18 +427,33 @@ export class Git {
427427
exception = new GitError(ex);
428428
});
429429
proc.once('close', (code, signal) => {
430-
// If the process exited normally or the caller didn't iterate over the complete stream, just resolve
431-
if (code === 0 || code === 141 /* SIGPIPE */) {
430+
if (code === 0) {
432431
resolve();
433432
return;
434433
}
435434

436435
if (signal === 'SIGTERM') {
437-
reject(
438-
new CancellationError(
439-
new CancelledRunError(proc.spawnargs.join(' '), true, code ?? undefined, signal),
440-
),
441-
);
436+
// If the caller aborted, just resolve
437+
if (spawnOpts.signal?.aborted) {
438+
resolve();
439+
} else {
440+
reject(
441+
new CancellationError(
442+
new CancelledRunError(proc.spawnargs.join(' '), true, code ?? undefined, signal),
443+
),
444+
);
445+
}
446+
return;
447+
}
448+
449+
// If the caller didn't read the complete stream, just resolve
450+
if (
451+
signal === 'SIGPIPE' ||
452+
code === 141 /* SIGPIPE */ ||
453+
// Effectively SIGPIPE on WSL & Linux?
454+
(code === 128 && stderrChunks.some(c => c.includes('Connection reset by peer')))
455+
) {
456+
resolve();
442457
return;
443458
}
444459

0 commit comments

Comments
 (0)