gatsbyjs/gatsby · error · Error
"app" chunk not found
Error message
"app" chunk not found
What it means
In optimizeChunks the plugin scans compilation.chunks for the chunk named 'app' to attach dangling CSS modules; not finding it means the expected app entry/chunk was absent at that hook — a build-internal invariant, often from customized entries or a changed Gatsby webpack setup.
Source
Thrown at packages/gatsby/src/utils/webpack/plugins/partial-hydration.ts:432
normalModuleFactory.hooks.parser
.for(`javascript/esm`)
.tap(this.name, parserCallback)
normalModuleFactory.hooks.parser
.for(`javascript/dynamic`)
.tap(this.name, parserCallback)
// add dangling css modules to the app entry
compilation.hooks.optimizeChunks.tap(this.name, () => {
let appChunk: webpack.Chunk | null = null
for (const chunk of compilation.chunks) {
if (chunk.name === `app`) {
appChunk = chunk
break
}
}
if (!appChunk) {
throw new Error(`"app" chunk not found`)
}
const modulesToInsertIntoApp: Array<webpack.Module> = []
for (const cssModule of this._collectedCssModules) {
const usedInChunks =
compilation.chunkGraph.getModuleChunksIterable(cssModule)
let isInAnyChunk = false
for (const _ of usedInChunks) {
isInAnyChunk = true
break
}
if (!isInAnyChunk) {
modulesToInsertIntoApp.push(cssModule)
}
}View on GitHub (pinned to e85d62f177)
Solutions
- Avoid webpack config changes that rename or remove the 'app' entry
- Update Gatsby to a version with partial-hydration chunk fixes
- Disable partial hydration if not needed
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at packages/gatsby/src/utils/webpack/plugins/partial-hydration.ts:432 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/06e25f478cb99fc0.
Report an issue: GitHub.