Skip to content

Commit a614aa5

Browse files
committed
fix: ensure lint worker errors aren't silenced (#75766)
Errors thrown by the lint worker would only surface the error if `JEST_WORKER_ID` is present. This check was not reliably truthy in all cases (eg, when run with the vercel CLI, `JEST_WORKER_ID` wasn't present) which meant the build would fail with no helpful error message. Outside of that, it was a brittle check because if jest-worker ever changed or removed this env, or we replaced the underlying worker library, this would start failing. This updates the check to be a more explicit env variable that we control. Fixes NEXT-3994
1 parent f27ce02 commit a614aa5

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

packages/next/src/lib/verify-typescript-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export async function verifyTypeScriptSetup({
164164
*/
165165

166166
// we are in a worker, print the error message and exit the process
167-
if (process.env.JEST_WORKER_ID) {
167+
if (process.env.IS_NEXT_WORKER) {
168168
if (err instanceof Error) {
169169
console.error(err.message)
170170
} else {

packages/next/src/lib/worker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class Worker {
4848
env: {
4949
...((farmOptions.forkOptions?.env || {}) as any),
5050
...process.env,
51+
IS_NEXT_WORKER: 'true',
5152
} as any,
5253
},
5354
}) as JestWorker
@@ -73,7 +74,7 @@ export class Worker {
7374
worker._child?.on('exit', (code, signal) => {
7475
if ((code || (signal && signal !== 'SIGINT')) && this._worker) {
7576
logger.error(
76-
`Static worker exited with code: ${code} and signal: ${signal}`
77+
`Next.js build worker exited with code: ${code} and signal: ${signal}`
7778
)
7879

7980
// We're restarting the worker, so we don't want to exit the parent process

test/production/app-dir/worker-restart/worker-restart.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('worker-restart', () => {
4141

4242
const output = stdout + stderr
4343
expect(output).toContain(
44-
'Static worker exited with code: null and signal: SIGKILL'
44+
'Next.js build worker exited with code: null and signal: SIGKILL'
4545
)
4646
})
4747
})

0 commit comments

Comments
 (0)