gatsbyjs/gatsby · error
Non-deterministic routing danger: Attempting to create page:
Error message
Non-deterministic routing danger: Attempting to create page: "${page.path}", but page "${alternateSlashPath}" already exists
This could lead to non-deterministic routing behavior What it means
In createPage (public actions), a new page's path collides with an existing page differing only by trailing slash (e.g. /about vs /about/). Because both would normalize to overlapping routes, this creates non-deterministic routing — which page wins depends on creation order — so Gatsby warns instead of silently overwriting.
Source
Thrown at packages/gatsby/src/redux/actions/public.js:461
// If the path doesn't have an initial forward slash, add it.
if (internalPage.path[0] !== `/`) {
internalPage.path = `/${internalPage.path}`
}
const oldPage: Page = store.getState().pages.get(internalPage.path)
const contextModified =
!!oldPage && !_.isEqual(oldPage.context, internalPage.context)
const componentModified =
!!oldPage && !_.isEqual(oldPage.component, internalPage.component)
const slicesModified =
!!oldPage && !_.isEqual(oldPage.slices, internalPage.slices)
const alternateSlashPath = page.path.endsWith(`/`)
? page.path.slice(0, -1)
: page.path + `/`
if (store.getState().pages.has(alternateSlashPath)) {
report.warn(
chalk.bold.yellow(`Non-deterministic routing danger: `) +
`Attempting to create page: "${page.path}", but page "${alternateSlashPath}" already exists\n` +
chalk.bold.yellow(
`This could lead to non-deterministic routing behavior`
)
)
}
// just so it's easier to c&p from createPage action creator for now - ideally it's DRYed
const { updatedAt, ...node } = internalPage
node.children = []
node.internal = {
type: `SitePage`,
contentDigest: createContentDigest(node),
}
node.id = `SitePage ${internalPage.path}`
const oldNode = getNode(node.id)
View on GitHub (pinned to e85d62f177)
Solutions
- Normalize paths before createPage: strip or consistently add the trailing slash (use `path === `/` ? ... : trim)` or the slash helper)
- Find the two createPage calls producing the duplicate and remove/merge one
- Ensure source data (CMS slugs) doesn't mix trailing-slash variants
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/gatsby/src/redux/actions/public.js:461 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/718db474a318190a.
Report an issue: GitHub.