gatsbyjs/gatsby · error · Error
An error occurred finding a node by it's type. This is likel
Error message
An error occurred finding a node by it's type. This is likely a bug in gatsby. If you experience this error please open an issue.
What it means
getNodesOfType is a helper inside the nodesByType reducer that lazily creates a Map for a node type and then reads it back. It throws if state.get(type) returns undefined immediately after state.set(type, new Map()), which is logically impossible for a normal Map and therefore treated as a Gatsby internal bug. The throw is a defensive non-null guard for TypeScript over a Map operation that should always succeed.
Source
Thrown at packages/gatsby/src/redux/reducers/nodes-by-type.ts:14
import { IGatsbyNode, IGatsbyState, ActionsUnion } from "../types"
const getNodesOfType = (
node: IGatsbyNode,
state: IGatsbyState["nodesByType"]
): Map<string, IGatsbyNode> => {
const { type } = node.internal
if (!state.has(type)) {
state.set(type, new Map())
}
const nodeByType = state.get(type)
if (!nodeByType) {
throw new Error(
`An error occurred finding a node by it's type. This is likely a bug in gatsby. If you experience this error please open an issue.`
)
}
return nodeByType
}
export const nodesByTypeReducer = (
state: IGatsbyState["nodesByType"] = new Map(),
action: ActionsUnion
): IGatsbyState["nodesByType"] => {
switch (action.type) {
case `DELETE_CACHE`:
return new Map()
case `CREATE_NODE`: {
const node = action.payload
const nodesOfType = getNodesOfType(node, state)View on GitHub (pinned to 8b06340921)
Solutions
- Report to Gatsby as an internal bug with the node type and full stack trace.
- Clear .cache and node_modules and reinstall/rebuild to rule out a corrupted build environment.
- Update Gatsby to the latest version.
Defensive patterns
Strategy: try-catch
Try / catch
// Defensive: this is an internal invariant; surface and reset.
try {
// ... node operations ...
} catch (e) {
if (/likely a bug in gatsby/.test(e.message)) {
report.error(e)
} else throw e
} Prevention
- Do not replace redux state Maps with custom non-conforming objects.
- Run gatsby clean if node-by-type state appears corrupted.
- Report reproducible occurrences upstream.
When it happens
Trigger: Dispatching any node action (CREATE_NODE, DELETE_NODE, etc.) whose node.internal.type triggers getNodesOfType, in the pathological case where Map.prototype.get returns undefined right after Map.prototype.set. Not reproducible through normal API usage.
Common situations: Effectively unreachable; would only surface from memory corruption, a custom Map-like state object violating Map semantics, or a severe runtime/JS engine bug. If reported, it is treated as a Gatsby defect.
Related errors
- If you encounter this error, it's probably a Gatsby internal
- Could not create more nodes. Maximum node count is reached:
- An ID must be provided when creating or setting job
- An ID must be provided when ending a job
- The plugin "${_.get(action, `plugin.name`, `anonymous`)}" tr
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/99affa0fc125cfba.
Report an issue: GitHub.