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): shut down worker pool after html generation #32366

Merged
merged 1 commit into from
Jul 14, 2021
Merged
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
8 changes: 7 additions & 1 deletion packages/gatsby/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ module.exports = async function build(program: IBuildArgs): Promise<void> {
workerPool,
buildSpan,
})
const waitWorkerPoolEnd = Promise.all(workerPool.end())

telemetry.addSiteMeasurement(`BUILD_END`, {
pagesCount: toRegenerate.length, // number of html files that will be written
Expand All @@ -243,6 +244,12 @@ module.exports = async function build(program: IBuildArgs): Promise<void> {
// This could occur due to queries being run which invoke sharp for instance
await waitUntilAllJobsComplete()

try {
await waitWorkerPoolEnd
} catch (e) {
report.warn(`Error when closing WorkerPool: ${e.message}`)
}

// Make sure we saved the latest state so we have all jobs cached
await db.saveState()

Expand All @@ -252,7 +259,6 @@ module.exports = async function build(program: IBuildArgs): Promise<void> {

buildSpan.finish()
await stopTracer()
workerPool.end()
buildActivity.end()

if (program.logPages) {
Expand Down