Skip to content

Commit 26d61f1

Browse files
authored
[backport] Turbopack: flush Node.js worker IPC on error (#84079)
1 parent e11e87a commit 26d61f1

File tree

1 file changed

+6
-4
lines changed
  • turbopack/crates/turbopack-node/js/src/ipc

1 file changed

+6
-4
lines changed

turbopack/crates/turbopack-node/js/src/ipc/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,20 @@ function createIpc<TIncoming, TOutgoing>(
168168
sendReady,
169169

170170
async sendError(error: Error): Promise<never> {
171+
let failed = false
171172
try {
172173
await send({
173174
type: 'error',
174175
...structuredError(error),
175176
})
176177
} catch (err) {
178+
// There's nothing we can do about errors that happen after this point, we can't tell anyone
179+
// about them.
177180
console.error('failed to send error back to rust:', err)
178-
// ignore and exit anyway
179-
process.exit(1)
181+
failed = true
180182
}
181-
182-
process.exit(0)
183+
await new Promise<void>((res) => socket.end(() => res()))
184+
process.exit(failed ? 1 : 0)
183185
},
184186
}
185187
}

0 commit comments

Comments
 (0)