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) #34896

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

// Start saving page.mode in the main process (while queries run in workers in parallel)
const waitMaterializePageMode = materializePageMode()

let waitForWorkerPoolRestart = Promise.resolve()
if (process.env.GATSBY_EXPERIMENTAL_PARALLEL_QUERY_RUNNING) {
await runQueriesInWorkersQueue(workerPool, queryIds, {
Expand Down Expand Up @@ -322,6 +325,7 @@ module.exports = async function build(
}

if (process.send && shouldGenerateEngines()) {
await waitMaterializePageMode
process.send({
type: `LOG_ACTION`,
action: {
Expand Down Expand Up @@ -401,9 +405,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