diff --git a/packages/next/src/build/webpack-build/index.ts b/packages/next/src/build/webpack-build/index.ts index c88c6781d7239d..5b34bbf49e8f87 100644 --- a/packages/next/src/build/webpack-build/index.ts +++ b/packages/next/src/build/webpack-build/index.ts @@ -2,9 +2,8 @@ import type { COMPILER_INDEXES } from '../../shared/lib/constants' import * as Log from '../output/log' import { NextBuildContext } from '../build-context' import type { BuildTraceContext } from '../webpack/plugins/next-trace-entrypoints-plugin' -import { Worker } from 'next/dist/compiled/jest-worker' +import { Worker } from '../../lib/worker' import origDebug from 'next/dist/compiled/debug' -import type { ChildProcess } from 'child_process' import path from 'path' import { exportTraceState, recordTraceEvents } from '../../trace' @@ -38,8 +37,13 @@ async function webpackBuildWithWorker( prunedBuildContext.pluginState = pluginState - const getWorker = (compilerName: string) => { - const _worker = new Worker(path.join(__dirname, 'impl.js'), { + const combinedResult = { + duration: 0, + buildTraceContext: {} as BuildTraceContext, + } + + for (const compilerName of compilerNames) { + const worker = new Worker(path.join(__dirname, 'impl.js'), { exposedMethods: ['workerMain'], numWorkers: 1, maxRetries: 0, @@ -50,31 +54,6 @@ async function webpackBuildWithWorker( }, }, }) as Worker & typeof import('./impl') - _worker.getStderr().pipe(process.stderr) - _worker.getStdout().pipe(process.stdout) - - for (const worker of ((_worker as any)._workerPool?._workers || []) as { - _child: ChildProcess - }[]) { - worker._child.on('exit', (code, signal) => { - if (code || (signal && signal !== 'SIGINT')) { - debug( - `Compiler ${compilerName} unexpectedly exited with code: ${code} and signal: ${signal}` - ) - } - }) - } - - return _worker - } - - const combinedResult = { - duration: 0, - buildTraceContext: {} as BuildTraceContext, - } - - for (const compilerName of compilerNames) { - const worker = getWorker(compilerName) const curResult = await worker.workerMain({ buildContext: prunedBuildContext, diff --git a/packages/next/src/lib/worker.ts b/packages/next/src/lib/worker.ts index aeeeaa1d59338e..ec8a4292c42dc9 100644 --- a/packages/next/src/lib/worker.ts +++ b/packages/next/src/lib/worker.ts @@ -50,8 +50,8 @@ export class Worker { // Get the node options without inspect and also remove the // --max-old-space-size flag as it can cause memory issues. const nodeOptions = getParsedNodeOptionsWithoutInspect() - delete nodeOptions['max-old-space-size'] - delete nodeOptions['max_old_space_size'] + // delete nodeOptions['max-old-space-size'] + // delete nodeOptions['max_old_space_size'] this._worker = new JestWorker(workerPath, { ...farmOptions,