Skip to content

Commit 43d60fb

Browse files
committed
Allow SyncCompiler.yieldUntilExit() for an exited compiler
Otherwise, running this in a `finally {}` block doesn't work when the compiler crashes.
1 parent bba6a4f commit 43d60fb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/src/sync-compiler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export class SyncEmbeddedCompiler {
2121
/** The buffers emitted by the child process's stderr. */
2222
readonly stderr$ = new Subject<Buffer>();
2323

24+
/** Whether the underlying compiler has already exited. */
25+
private exited = false;
26+
2427
/** Writes `buffer` to the child process's stdin. */
2528
writeStdin(buffer: Buffer): void {
2629
this.process.stdin.write(buffer);
@@ -38,14 +41,15 @@ export class SyncEmbeddedCompiler {
3841
return true;
3942

4043
case 'exit':
44+
this.exited = true;
4145
return false;
4246
}
4347
}
4448

4549
/** Blocks until the underlying process exits. */
4650
yieldUntilExit(): void {
47-
while (this.yield()) {
48-
// Any events will be handled by `this.yield()`.
51+
while (!this.exited) {
52+
this.yield();
4953
}
5054
}
5155

0 commit comments

Comments
 (0)