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);