Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure lint worker errors aren't silenced #75766

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/src/lib/verify-typescript-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export async function verifyTypeScriptSetup({
*/

// we are in a worker, print the error message and exit the process
if (process.env.JEST_WORKER_ID) {
if (process.env.IS_NEXT_WORKER) {
if (err instanceof Error) {
console.error(err.message)
} else {
Expand Down
3 changes: 2 additions & 1 deletion packages/next/src/lib/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class Worker {
env: {
...((farmOptions.forkOptions?.env || {}) as any),
...process.env,
IS_NEXT_WORKER: 'true',
} as any,
},
maxRetries: 0,
Expand All @@ -75,7 +76,7 @@ export class Worker {
worker._child?.on('exit', (code, signal) => {
if ((code || (signal && signal !== 'SIGINT')) && this._worker) {
logger.error(
`Static worker exited with code: ${code} and signal: ${signal}`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by rename since we use this for more than just SSG

`Next.js build 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
Expand Down
12 changes: 6 additions & 6 deletions test/production/app-dir/build-output/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('production - app dir - build output', () => {

it('should log errors not caught by the worker without terminating the process', async () => {
expect(output).toContain('Error: Boom')
expect(output).not.toContain('Static worker exited with code: 78')
expect(output).not.toContain('Next.js build worker exited with code: 78')

const $ = await next.render$('/uncaught-error')
expect($('#sentinel').text()).toEqual('at buildtime')
Expand All @@ -66,7 +66,7 @@ describe('production - app dir - build output', () => {
const { cliOutput } = await next.build()
await next.deleteFile('app/out-of-band-dynamic-api/page.tsx')

expect(cliOutput).toContain('Static worker exited with code: 78')
expect(cliOutput).toContain('Next.js build worker exited with code: 78')
})

it('should fail the build if you use a dynamic API outside of a render context - headers', async () => {
Expand All @@ -87,7 +87,7 @@ describe('production - app dir - build output', () => {
const { cliOutput } = await next.build()
await next.deleteFile('app/out-of-band-dynamic-api/page.tsx')

expect(cliOutput).toContain('Static worker exited with code: 78')
expect(cliOutput).toContain('Next.js build worker exited with code: 78')
})

it('should fail the build if you use a dynamic API outside of a render context - searchParams', async () => {
Expand All @@ -106,7 +106,7 @@ describe('production - app dir - build output', () => {
const { cliOutput } = await next.build()
await next.deleteFile('app/out-of-band-dynamic-api/page.tsx')

expect(cliOutput).toContain('Static worker exited with code: 78')
expect(cliOutput).toContain('Next.js build worker exited with code: 78')
})

it('should fail the build if you use a dynamic API outside of a render context - redirect', async () => {
Expand All @@ -127,7 +127,7 @@ describe('production - app dir - build output', () => {
const { cliOutput } = await next.build()
await next.deleteFile('app/out-of-band-dynamic-api/page.tsx')

expect(cliOutput).toContain('Static worker exited with code: 78')
expect(cliOutput).toContain('Next.js build worker exited with code: 78')
})

it('should fail the build if you use a dynamic API outside of a render context - notFound', async () => {
Expand All @@ -148,6 +148,6 @@ describe('production - app dir - build output', () => {
const { cliOutput } = await next.build()
await next.deleteFile('app/out-of-band-dynamic-api/page.tsx')

expect(cliOutput).toContain('Static worker exited with code: 78')
expect(cliOutput).toContain('Next.js build worker exited with code: 78')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('worker-restart', () => {

const output = stdout + stderr
expect(output).toContain(
'Static worker exited with code: null and signal: SIGKILL'
'Next.js build worker exited with code: null and signal: SIGKILL'
)
})
})
Loading