Skip to content
Draft
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
18 changes: 16 additions & 2 deletions packages/next/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
"262": "%s %s",
"263": "Invariant: static generation store missing in %s",
"264": "Failed to find Server Action \"%s\". This request might be from an older or newer deployment. %s\\nRead more: https://nextjs.org/docs/messages/failed-to-find-server-action",
"265": "Farm is ended, no more calls can be done to it",
"265": "Worker is ended, no more calls can be done to it",
"266": "Multiple children were passed to <Link> with \\`href\\` of \\`%s\\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children%s",
"267": "Dynamic href \\`%s\\` found in <Link> while using the \\`/app\\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href",
"268": "Failed to prefetch: %s",
Expand Down Expand Up @@ -1073,5 +1073,19 @@
"1072": "Missing segment data: <head>",
"1073": "Expected static stage body to be available",
"1074": "Page \"%s\" cannot use both \"use client\" and export const \"unstable_instant\".",
"1075": "Page \"%s\" cannot export \"unstable_instant\" from a Client Component module. To use this API, convert this module to a Server Component by removing the \"use client\" directive."
"1075": "Page \"%s\" cannot export \"unstable_instant\" from a Client Component module. To use this API, convert this module to a Server Component by removing the \"use client\" directive.",
"1076": "Worker pool is ending, no more calls can be made",
"1077": "Worker exited with code %s%s",
"1078": "This file must be run as a worker thread",
"1079": "Worker pool closed",
"1080": "Child can only be used on a forked process",
"1081": "Error when calling setup: %s",
"1082": "Worker pool ended before task could be processed",
"1083": "\"null\" or \"undefined\" thrown",
"1084": "Unexpected request from parent process: %s",
"1085": "Worker exited unexpectedly with code %s, signal %s",
"1086": "Worker restarted due to timeout",
"1087": "maxBootingWorkers must be at least 1",
"1088": "Worker exited during shutdown",
"1089": "Worker pool ended while requests were in-flight"
}
6 changes: 3 additions & 3 deletions packages/next/src/build/collect-build-traces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export async function collectBuildTraces({

const sharedIgnores = [
'**/next/dist/compiled/next-server/**/*.dev.js',
...(isStandalone ? [] : ['**/next/dist/compiled/jest-worker/**/*']),
...(isStandalone ? [] : ['**/next/dist/lib/worker/worker-*-child*']),
'**/next/dist/compiled/webpack/*',
'**/node_modules/webpack5/**/*',
'**/next/dist/server/lib/route-resolver*',
Expand Down Expand Up @@ -281,12 +281,12 @@ export async function collectBuildTraces({
if (isStandalone) {
addToTracedFiles(
'',
require.resolve('next/dist/compiled/jest-worker/processChild'),
require.resolve('../lib/worker/worker-process-child'),
serverTracedFiles
)
addToTracedFiles(
'',
require.resolve('next/dist/compiled/jest-worker/threadChild'),
require.resolve('../lib/worker/worker-thread-child'),
serverTracedFiles
)
}
Expand Down
8 changes: 4 additions & 4 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,9 @@ export function createStaticWorker(
): StaticWorker {
const { numberOfWorkers, debuggerPortOffset, progress } = options
return new Worker(staticWorkerPath, {
workerName: 'Next.js static worker',
logger: Log,
numWorkers: numberOfWorkers,
maxWorkers: numberOfWorkers,
onActivity: () => {
progress?.run()
},
Expand Down Expand Up @@ -1647,9 +1648,8 @@ export default async function build(
const buildTraceWorker = new Worker(
require.resolve('./collect-build-traces'),
{
debuggerPortOffset: -1,
isolatedMemory: false,
numWorkers: 1,
workerName: 'Next.js build trace worker',
maxWorkers: 1,
exposedMethods: ['collectBuildTraces'],
forkOptions: process.env.NEXT_CPU_PROF
? {
Expand Down
5 changes: 2 additions & 3 deletions packages/next/src/build/turbopack-build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ async function turbopackBuildWithWorker(): ReturnType<
> {
try {
const worker = new Worker(path.join(__dirname, 'impl.js'), {
workerName: 'Next.js turbopack build worker',
exposedMethods: ['workerMain', 'waitForShutdown'],
enableWorkerThreads: true,
debuggerPortOffset: -1,
isolatedMemory: false,
numWorkers: 1,
maxWorkers: 1,
maxRetries: 0,
forkOptions: {
env: {
Expand Down
95 changes: 42 additions & 53 deletions packages/next/src/build/type-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as Log from './output/log'
import { Worker } from '../lib/worker'
import createSpinner from './spinner'
import { eventTypeCheckCompleted } from '../telemetry/events'
import isError from '../lib/is-error'

import { hrtimeDurationToString } from './duration-to-string'

/**
Expand Down Expand Up @@ -43,10 +43,9 @@ function verifyAndRunTypeScript(
typeCheckWorker = new Worker(
require.resolve('../lib/verify-typescript-setup'),
{
workerName: 'Next.js type check worker',
exposedMethods: ['verifyAndRunTypeScript'],
debuggerPortOffset: -1,
isolatedMemory: false,
numWorkers: 1,
maxWorkers: 1,
enableWorkerThreads,
maxRetries: 0,
}
Expand Down Expand Up @@ -124,57 +123,47 @@ export async function startTypeChecking({

const typeCheckAndLintStart = process.hrtime()

try {
const [verifyResult, typeCheckEnd] = await nextBuildSpan
.traceChild('run-typescript')
.traceAsyncFn(() =>
verifyAndRunTypeScript(
dir,
config.distDir,
Boolean(config.experimental.strictRouteTypes),
!ignoreTypeScriptErrors,
config.typescript.tsconfigPath,
Boolean(config.typedRoutes),
config.images.disableStaticImages,
cacheDir,
config.experimental.workerThreads,
!!appDir,
!!pagesDir,
appDir,
pagesDir,
debugBuildPaths
).then((resolved) => {
const checkEnd = process.hrtime(typeCheckAndLintStart)
return [resolved, checkEnd] as const
})
)
const [verifyResult, typeCheckEnd] = await nextBuildSpan
.traceChild('run-typescript')
.traceAsyncFn(() =>
verifyAndRunTypeScript(
dir,
config.distDir,
Boolean(config.experimental.strictRouteTypes),
!ignoreTypeScriptErrors,
config.typescript.tsconfigPath,
Boolean(config.typedRoutes),
config.images.disableStaticImages,
cacheDir,
config.experimental.workerThreads,
!!appDir,
!!pagesDir,
appDir,
pagesDir,
debugBuildPaths
).then((resolved) => {
const checkEnd = process.hrtime(typeCheckAndLintStart)
return [resolved, checkEnd] as const
})
)

if (typeCheckingSpinner) {
typeCheckingSpinner.stop()
}
if (typeCheckingSpinner) {
typeCheckingSpinner.stop()
}

createSpinner(
`Finished TypeScript${ignoreTypeScriptErrors ? ' config validation' : ''} in ${hrtimeDurationToString(typeCheckEnd)}`
)?.stopAndPersist()
createSpinner(
`Finished TypeScript${ignoreTypeScriptErrors ? ' config validation' : ''} in ${hrtimeDurationToString(typeCheckEnd)}`
)?.stopAndPersist()

if (!ignoreTypeScriptErrors && verifyResult) {
telemetry.record(
eventTypeCheckCompleted({
durationInSeconds: typeCheckEnd[0],
typescriptVersion: verifyResult.version,
inputFilesCount: verifyResult.result?.inputFilesCount,
totalFilesCount: verifyResult.result?.totalFilesCount,
incremental: verifyResult.result?.incremental,
})
)
}
} catch (err) {
// prevent showing jest-worker internal error as it
// isn't helpful for users and clutters output
if (isError(err) && err.message === 'Call retries were exceeded') {
await telemetry.flush()
process.exit(1)
}
throw err
if (!ignoreTypeScriptErrors && verifyResult) {
telemetry.record(
eventTypeCheckCompleted({
durationInSeconds: typeCheckEnd[0],
typescriptVersion: verifyResult.version,
inputFilesCount: verifyResult.result?.inputFilesCount,
totalFilesCount: verifyResult.result?.totalFilesCount,
incremental: verifyResult.result?.incremental,
})
)
}
}
5 changes: 2 additions & 3 deletions packages/next/src/build/webpack-build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ async function webpackBuildWithWorker(

for (const compilerName of compilerNames) {
const worker = new Worker(path.join(__dirname, 'impl.js'), {
workerName: `Next.js webpack worker (${compilerName})`,
exposedMethods: ['workerMain'],
debuggerPortOffset: -1,
isolatedMemory: false,
numWorkers: 1,
maxWorkers: 1,
maxRetries: 0,
forkOptions: {
env: {
Expand Down
21 changes: 0 additions & 21 deletions packages/next/src/compiled/jest-worker/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/src/compiled/jest-worker/index.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/src/compiled/jest-worker/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/src/compiled/jest-worker/processChild.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/src/compiled/jest-worker/threadChild.js

This file was deleted.

Loading
Loading