Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby): wait for LMDB upserts to finish before emitting ENGINES_READY #34853

Merged
merged 9 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
11 changes: 8 additions & 3 deletions packages/gatsby/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,13 @@ module.exports = async function build(
)
}

// Start saving page.mode in the main process (while queries run in workers in parallel)
let waitMaterializePageMode = Promise.resolve()

let waitForWorkerPoolRestart = Promise.resolve()
if (process.env.GATSBY_EXPERIMENTAL_PARALLEL_QUERY_RUNNING) {
waitMaterializePageMode = materializePageMode()

await runQueriesInWorkersQueue(workerPool, queryIds, {
parentSpan: buildSpan,
})
Expand All @@ -310,6 +315,8 @@ module.exports = async function build(
parentSpan: buildSpan,
store,
})

waitMaterializePageMode = materializePageMode()
pieh marked this conversation as resolved.
Show resolved Hide resolved
}

// create scope so we don't leak state object
Expand All @@ -322,6 +329,7 @@ module.exports = async function build(
}

if (process.send && shouldGenerateEngines()) {
await waitMaterializePageMode
process.send({
type: `LOG_ACTION`,
action: {
Expand Down Expand Up @@ -401,9 +409,6 @@ module.exports = async function build(

await waitForWorkerPoolRestart

// Start saving page.mode in the main process (while HTML is generated in workers in parallel)
const waitMaterializePageMode = materializePageMode()

const { toRegenerate, toDelete } =
await buildHTMLPagesAndDeleteStaleArtifacts({
program,
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby/src/utils/page-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { reportOnce } from "./report-once"
import { ROUTES_DIRECTORY } from "../constants"
import { Runner } from "../bootstrap/create-graphql-runner"
import { getDataStore } from "../datastore"

type IPageConfigFn = (arg: { params: Record<string, unknown> }) => {
defer: boolean
Expand Down Expand Up @@ -111,6 +112,7 @@ export async function materializePageMode(): Promise<void> {
await new Promise(resolve => setImmediate(resolve))
}
}
await getDataStore().ready()
}

export async function preparePageTemplateConfigs(
Expand Down