Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 7 additions & 1 deletion packages/next/server/next-dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,16 @@ export default class DevServer extends Server {
// from waiting on them for the page to load in dev mode

const __getStaticPaths = async () => {
const { publicRuntimeConfig, serverRuntimeConfig } = this.nextConfig

const paths = await this.staticPathsWorker.loadStaticPaths(
this.distDir,
pathname,
!this.renderOpts.dev && this._isLikeServerless
!this.renderOpts.dev && this._isLikeServerless,
{
publicRuntimeConfig,
serverRuntimeConfig,
}
)
return paths
}
Expand Down
8 changes: 7 additions & 1 deletion packages/next/server/static-paths-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { buildStaticPaths } from '../build/utils'
import { loadComponents } from '../next-server/server/load-components'
import '../next-server/server/node-polyfill-fetch'

type RuntimeConfig = any

let workerWasUsed = false

// we call getStaticPaths in a separate process to ensure
Expand All @@ -10,14 +12,18 @@ let workerWasUsed = false
export async function loadStaticPaths(
distDir: string,
pathname: string,
serverless: boolean
serverless: boolean,
config: RuntimeConfig
) {
// we only want to use each worker once to prevent any invalid
// caches
if (workerWasUsed) {
process.exit(1)
}

// update work memory runtime-config
require('./../next-server/lib/runtime-config').setConfig(config)

const components = await loadComponents(distDir, pathname, serverless)

if (!components.getStaticPaths) {
Expand Down