@@ -194,10 +194,6 @@ import {
194194import { FallbackMode , fallbackModeToFallbackField } from '../lib/fallback'
195195import { RenderingMode } from './rendering-mode'
196196import { getParamKeys } from '../server/request/fallback-params'
197- import {
198- formatNodeOptions ,
199- getParsedNodeOptionsWithoutInspect ,
200- } from '../server/lib/utils'
201197import { InvariantError } from '../shared/lib/invariant-error'
202198import { HTML_LIMITED_BOT_UA_RE_STRING } from '../shared/lib/router/utils/is-bot'
203199import type { UseCacheTrackerKey } from './webpack/plugins/telemetry-plugin/use-cache-tracker-utils'
@@ -743,17 +739,15 @@ const staticWorkerExposedMethods = [
743739type StaticWorker = typeof import ( './worker' ) & Worker
744740export function createStaticWorker (
745741 config : NextConfigComplete ,
746- progress ?: {
747- run : ( ) => void
748- clear : ( ) => void
742+ options : {
743+ debuggerPortOffset : number
744+ progress ?: {
745+ run : ( ) => void
746+ clear : ( ) => void
747+ }
749748 }
750749) : StaticWorker {
751- // Get the node options without inspect and also remove the
752- // --max-old-space-size flag as it can cause memory issues.
753- const nodeOptions = getParsedNodeOptionsWithoutInspect ( )
754- delete nodeOptions [ 'max-old-space-size' ]
755- delete nodeOptions [ 'max_old_space_size' ]
756-
750+ const { debuggerPortOffset, progress } = options
757751 return new Worker ( staticWorkerPath , {
758752 logger : Log ,
759753 numWorkers : getNumberOfWorkers ( config ) ,
@@ -763,11 +757,9 @@ export function createStaticWorker(
763757 onActivityAbort : ( ) => {
764758 progress ?. clear ( )
765759 } ,
766- forkOptions : {
767- env : {
768- NODE_OPTIONS : formatNodeOptions ( nodeOptions ) ,
769- } ,
770- } ,
760+ debuggerPortOffset,
761+ // remove --max-old-space-size flag as it can cause memory issues.
762+ isolatedMemory : true ,
771763 enableWorkerThreads : config . experimental . workerThreads ,
772764 exposedMethods : staticWorkerExposedMethods ,
773765 } ) as StaticWorker
@@ -1496,6 +1488,8 @@ export default async function build(
14961488 const buildTraceWorker = new Worker (
14971489 require . resolve ( './collect-build-traces' ) ,
14981490 {
1491+ debuggerPortOffset : - 1 ,
1492+ isolatedMemory : false ,
14991493 numWorkers : 1 ,
15001494 exposedMethods : [ 'collectBuildTraces' ] ,
15011495 }
@@ -1652,7 +1646,7 @@ export default async function build(
16521646
16531647 process . env . NEXT_PHASE = PHASE_PRODUCTION_BUILD
16541648
1655- const worker = createStaticWorker ( config )
1649+ const worker = createStaticWorker ( config , { debuggerPortOffset : - 1 } )
16561650
16571651 const analysisBegin = process . hrtime ( )
16581652 const staticCheckSpan = nextBuildSpan . traceChild ( 'static-check' )
0 commit comments