gatsbyjs/gatsby · error
Error when closing WorkerPool: ${e.message}
Error message
Error when closing WorkerPool: ${e.message} What it means
At the end of gatsby build, after onPostBuild hooks, the worker pool termination promise (waitWorkerPoolEnd) is awaited in a try/catch. If shutting down worker threads fails (a worker crashed or hung), Gatsby logs this warning with the underlying error message but lets the build finish, since real work is already complete.
Source
Thrown at packages/gatsby/src/commands/build.ts:569
const postBuildActivityTimer = report.activityTimer(`onPostBuild`, {
parentSpan: buildSpan,
})
postBuildActivityTimer.start()
await apiRunnerNode(`onPostBuild`, {
graphql: gatsbyNodeGraphQLFunction,
parentSpan: postBuildActivityTimer.span,
})
postBuildActivityTimer.end()
// Wait for any jobs that were started in onPostBuild
// 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()
const state = store.getState()
reporter._renderPageTree({
components: state.components,
functions: state.functions,
pages: state.pages,
root: state.program.directory,
})
if (process.send) {
const gatsbyCloudConfig = constructConfigObject(state.config)
process.send({
type: `LOG_ACTION`,View on GitHub (pinned to e85d62f177)
Solutions
- Inspect the logged inner error for a worker crash (often OOM or a native module failure in sharp/jimp workers)
- Retry the build; transient worker termination failures usually do not recur
- Reduce parallelism or upgrade Node/native deps if workers repeatedly fail to exit
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/gatsby/src/commands/build.ts:569 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of gatsbyjs/gatsby@e85d62f177 (2026-08-26).
Data as JSON: /api/errors/e27c18632859935b.
Report an issue: GitHub.