From ced2441e203acd7b86b6f9caca2e61149a3c33be Mon Sep 17 00:00:00 2001 From: Raymond Zhao Date: Fri, 21 Jan 2022 10:40:41 -0800 Subject: [PATCH] Add a delay, mitigates #141053 --- src/vs/code/node/cli.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts index 500b11f00ba..8aac55005d4 100644 --- a/src/vs/code/node/cli.ts +++ b/src/vs/code/node/cli.ts @@ -401,7 +401,11 @@ export async function main(argv: string[]): Promise { 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);