From bf45b786cdb868085b5eae965a99b55f1c06849b Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Mon, 22 Sep 2025 14:41:54 +0200 Subject: [PATCH] Turbopack: flush Node.js worker IPC on error --- turbopack/crates/turbopack-node/js/src/ipc/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/turbopack/crates/turbopack-node/js/src/ipc/index.ts b/turbopack/crates/turbopack-node/js/src/ipc/index.ts index 83f29f3296a8a4..3868cf7ddeff30 100644 --- a/turbopack/crates/turbopack-node/js/src/ipc/index.ts +++ b/turbopack/crates/turbopack-node/js/src/ipc/index.ts @@ -168,18 +168,20 @@ function createIpc( sendReady, async sendError(error: Error): Promise { + let failed = false try { await send({ type: 'error', ...structuredError(error), }) } catch (err) { + // There's nothing we can do about errors that happen after this point, we can't tell anyone + // about them. console.error('failed to send error back to rust:', err) - // ignore and exit anyway - process.exit(1) + failed = true } - - process.exit(0) + await new Promise((res) => socket.end(() => res())) + process.exit(failed ? 1 : 0) }, } }