Skip to content

Commit e411fd1

Browse files
authored
used shared worker for lint & typecheck steps (vercel#74154)
Similar to vercel#73138, this removes the direct usage of `jest-worker` for the linting/typechecking step in favor of the shared worker that has built-in handling for propagating errors to the parent process. This is to ensure that if the worker performing the typechecking/linting receives a SIGKILL signal (which could happen with an OOM error), that the parent process exits appropriately.
1 parent b9416d2 commit e411fd1

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

packages/next/src/build/type-check.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Span } from '../trace'
44

55
import path from 'path'
66
import * as Log from './output/log'
7-
import { Worker as JestWorker } from 'next/dist/compiled/jest-worker'
7+
import { Worker } from '../lib/worker'
88
import { verifyAndLint } from '../lib/verifyAndLint'
99
import createSpinner from './spinner'
1010
import { eventTypeCheckCompleted } from '../telemetry/events'
@@ -30,20 +30,18 @@ function verifyTypeScriptSetup(
3030
hasAppDir: boolean,
3131
hasPagesDir: boolean
3232
) {
33-
const typeCheckWorker = new JestWorker(
33+
const typeCheckWorker = new Worker(
3434
require.resolve('../lib/verify-typescript-setup'),
3535
{
36+
exposedMethods: ['verifyTypeScriptSetup'],
3637
numWorkers: 1,
3738
enableWorkerThreads,
3839
maxRetries: 0,
3940
}
40-
) as JestWorker & {
41+
) as Worker & {
4142
verifyTypeScriptSetup: typeof import('../lib/verify-typescript-setup').verifyTypeScriptSetup
4243
}
4344

44-
typeCheckWorker.getStdout().pipe(process.stdout)
45-
typeCheckWorker.getStderr().pipe(process.stderr)
46-
4745
return typeCheckWorker
4846
.verifyTypeScriptSetup({
4947
dir,

packages/next/src/lib/verifyAndLint.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { red } from './picocolors'
2-
import { Worker } from 'next/dist/compiled/jest-worker'
2+
import { Worker } from './worker'
33
import { existsSync } from 'fs'
44
import { join } from 'path'
55
import { ESLINT_DEFAULT_DIRS } from './constants'
@@ -23,16 +23,14 @@ export async function verifyAndLint(
2323

2424
try {
2525
lintWorkers = new Worker(require.resolve('./eslint/runLintCheck'), {
26+
exposedMethods: ['runLintCheck'],
2627
numWorkers: 1,
2728
enableWorkerThreads,
2829
maxRetries: 0,
2930
}) as Worker & {
3031
runLintCheck: typeof import('./eslint/runLintCheck').runLintCheck
3132
}
3233

33-
lintWorkers.getStdout().pipe(process.stdout)
34-
lintWorkers.getStderr().pipe(process.stderr)
35-
3634
const lintDirs = (configLintDirs ?? ESLINT_DEFAULT_DIRS).reduce(
3735
(res: string[], d: string) => {
3836
const currDir = join(dir, d)

0 commit comments

Comments
 (0)