Unverified Commit c17e225b authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

ensure export workers that are killed bubble up to parent process (#70997)

When a static worker exits, we log the error but it doesn't get
propagated to the parent process, which can cause the build to hang. If
we're going to log an error about a static worker being forced to exit,
this calls exit on the parent process.

Closes NDX-364
parent 541167b9
...@@ -80,6 +80,9 @@ export class Worker { ...@@ -80,6 +80,9 @@ export class Worker {
logger.error( logger.error(
`Static worker exited with code: ${code} and signal: ${signal}` `Static worker exited with code: ${code} and signal: ${signal}`
) )
// if a child process doesn't exit gracefully, we want to bubble up the exit code to the parent process
process.exit(code ?? 1)
} }
}) })
......
export default function Page() {
process.kill(process.pid, 'SIGKILL')
return <div>Kaboom</div>
}
export default function Layout({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}
export default function Page() {
return <div>Hello World</div>
}
...@@ -43,4 +43,20 @@ describe('worker-restart', () => { ...@@ -43,4 +43,20 @@ describe('worker-restart', () => {
) )
expect(output).toContain('Failed to build /page: / after 3 attempts.') expect(output).toContain('Failed to build /page: / after 3 attempts.')
}) })
it('should fail the build if a worker process is killed', async () => {
const { stdout, stderr } = await nextBuild(
__dirname + '/fixtures/worker-kill',
[],
{
stdout: true,
stderr: true,
}
)
const output = stdout + stderr
expect(output).toContain(
'Static worker exited with code: null and signal: SIGKILL'
)
})
}) })
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