Skip to content

Commit

Permalink
Fix export worker
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed May 5, 2023
1 parent e6a0db9 commit 95638e2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3056,15 +3056,36 @@ export default async function build(
if (config.output === 'export') {
const exportApp: typeof import('../export').default =
require('../export').default

const pagesWorker = createStaticWorker('pages')
const appWorker = createStaticWorker('app')

const options: ExportOptions = {
isInvokedFromCli: false,
nextConfig: config,
hasAppDir,
silent: true,
threads: config.experimental.cpus,
outdir: path.join(dir, configOutDir),
exportAppPageWorker: sharedPool
? appWorker.exportPage.bind(appWorker)
: undefined,
exportPageWorker: sharedPool
? pagesWorker.exportPage.bind(pagesWorker)
: undefined,
endWorker: sharedPool
? async () => {
await pagesWorker.end()
await appWorker.end()
}
: undefined,
}

await exportApp(dir, options, nextBuildSpan)

// ensure the worker is not left hanging
pagesWorker.close()
appWorker.close()
}

await nextBuildSpan
Expand Down

0 comments on commit 95638e2

Please sign in to comment.