Add a delay, mitigates #141053

This commit is contained in:
Raymond Zhao
2022-01-21 10:40:41 -08:00
parent a9e136f1f4
commit ced2441e20
+5 -1
View File
@@ -401,7 +401,11 @@ export async function main(argv: string[]): Promise<any> {
const stream = outputType === 'stdout' ? process.stdout : process.stderr;
const cts = new CancellationTokenSource();
child.on('close', () => cts.dispose(true));
child.on('close', () => {
// We must dispose the token to stop watching,
// but the watcher might still be reading data.
setTimeout(() => cts.dispose(true), 200);
});
await watchFileContents(tmpName, chunk => stream.write(chunk), () => { /* ignore */ }, cts.token);
} finally {
unlinkSync(tmpName);