Skip to content

Commit c1fd3d7

Browse files
authored
Retry failed umount after a delay (microsoft#78)
1 parent 1941809 commit c1fd3d7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/main.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,21 @@ export async function mainAsync(params: GitParams | UserParams): Promise<void> {
641641
await execAsync(processCwd, "sudo umount " + downloadDir);
642642
}
643643
catch (e) {
644-
await execAsync(processCwd, `pstree -palT`);
645-
throw e;
644+
// HACK: Sometimes the server lingers for a brief period, so retry.
645+
// Obviously, it would be better to have a way to know when it is gone-gone,
646+
// but Linux doesn't provide such a mechanism for non-child processes.
647+
// (You can poll for a process with the given PID after sending a kill signal,
648+
// but best practice is to guard against the possibility of a new process
649+
// being given the same PID.)
650+
try {
651+
console.log("umount failed - trying again after delay");
652+
await new Promise(resolve => setTimeout(resolve, 5000));
653+
await execAsync(processCwd, "sudo umount " + downloadDir);
654+
}
655+
catch {
656+
await execAsync(processCwd, `pstree -palT`);
657+
throw e;
658+
}
646659
}
647660
}
648661
}

0 commit comments

Comments
 (0)