Unverified Commit 9cf9183e authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: flush Node.js worker IPC on error (#84077)

If the Nodejs process exited too quickly after `sendError`, Turbopack never received the error message and then  previously crashed with panics such as 
```
- Execution of PostCssTransformedAsset::process failed
- creating new process
- reading packet length
- unexpected end of file
```

Now, flush the socket before calling `process.exit()`
parent 237f1428
...@@ -169,18 +169,20 @@ function createIpc<TIncoming, TOutgoing>( ...@@ -169,18 +169,20 @@ function createIpc<TIncoming, TOutgoing>(
sendReady, sendReady,
async sendError(error: Error): Promise<never> { async sendError(error: Error): Promise<never> {
let failed = false
try { try {
await send({ await send({
type: 'error', type: 'error',
...structuredError(error), ...structuredError(error),
}) })
} catch (err) { } 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) console.error('failed to send error back to rust:', err)
// ignore and exit anyway failed = true
process.exit(1)
} }
await new Promise<void>((res) => socket.end(() => res()))
process.exit(0) process.exit(failed ? 1 : 0)
}, },
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment