Skip to content

Commit

Permalink
fix(gatsby): wait for LMDB upserts to finish before emitting ENGINES_…
Browse files Browse the repository at this point in the history
…READY (#34853)
  • Loading branch information
pieh authored Feb 21, 2022
1 parent b2c1092 commit b4637c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit b4637c0

Please sign in to comment.