gatsbyjs/gatsby · error

page not found

Error message

page not found

What it means

During develop SSR, ensurePathComponentInSSRBundle receives a page object. The comment 'This shouldn't happen' signals this is an internal invariant -- a page lookup returned undefined/falsy. The panic passes the falsy page value as context, which is not useful but indicates a lookup-by-path failure in the SSR request pipeline.

Source

Thrown at packages/gatsby/src/utils/dev-ssr/render-dev-html.ts:98

        resolve(found)
      }
    })
    stream.on(`error`, function () {
      resolve(found)
    })
    stream.on(`close`, function () {
      resolve(found)
    })
  })

const ensurePathComponentInSSRBundle = async (
  page: IGatsbyPage,
  directory: string,
  allowTimedFallback: boolean
): Promise<boolean> => {
  // This shouldn't happen.
  if (!page) {
    report.panic(`page not found`, page)
  }

  // Now check if it's written to the correct path
  const htmlComponentRendererPath = nodePath.join(
    directory,
    ROUTES_DIRECTORY,
    `render-page.js`
  )

  // This search takes 1-10ms
  // We do it as there can be a race conditions where two pages
  // are requested at the same time which means that both are told render-page.js
  // has changed when the first page is complete meaning the second
  // page's component won't be in the render meaning its SSR will fail.
  let found = await searchFileForString(
    page.componentChunkName,
    htmlComponentRendererPath
  )

View on GitHub (pinned to 8b06340921)

Solutions

  1. Refresh the browser -- this is often a transient dev-server state desync.
  2. Run `gatsby clean` and restart `gatsby develop`.
  3. Verify the page path being requested actually exists (check gatsby-page-utils / page-creator output).
  4. If a custom page-creation plugin is involved, ensure it creates pages synchronously and correctly in createPages.
Defensive patterns

Strategy: validation

Validate before calling

// Validate page exists before SSR request handling
function isValidPage(page) {
  return page != null && typeof page.path === 'string' && typeof page.componentChunkName === 'string'
}

if (!isValidPage(requestedPage)) {
  return { statusCode: 404, body: 'Page not found' }
}

Type guard

function isGatsbyPage(page) {
  return (
    typeof page === 'object' &&
    page !== null &&
    typeof page.path === 'string' &&
    typeof page.componentChunkName === 'string'
  )
}

Prevention

When it happens

Trigger: A request comes in for a page path, the page is looked up in the store/pages map, and the result is undefined. This happens during dev-SSR when the page does not exist in Redux state -- e.g. after a page was deleted but before the dev server invalidated it, or a race condition during page recreation.

Common situations: Navigating to a page path in develop that was just deleted or renamed. A race condition where the page store is mid-update during a request. An incorrect page path in a Link component pointing to a non-existent route. Internal state desync during rapid edits.

Related errors


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/6bfae7c11b58c359. Report an issue: GitHub.