gatsbyjs/gatsby · error
Page "${pagePath}" doesn't exist. It might have been deleted
Error message
Page "${pagePath}" doesn't exist. It might have been deleted recently. What it means
getPageData/doGetPageData first checks the redux pages map; if pages.has(pagePath) is false the page was never created (or was deleted) and the request cannot be served, so it throws.
Source
Thrown at packages/gatsby/src/utils/get-page-data.ts:27
const DEFAULT_WAIT_TIMEOUT = 15 * 1000
export const RETRY_INTERVAL = 5 * 1000
export async function getPageData(
pagePath: string,
waitForMS: number = DEFAULT_WAIT_TIMEOUT
): Promise<IPageDataWithQueryResult> {
return doGetPageData(pagePath, waitForMS, waitForMS)
}
async function doGetPageData(
pagePath: string,
waitForMS: number,
initialWaitForMs: number
): Promise<IPageDataWithQueryResult> {
const { queries, pendingPageDataWrites, pages } = store.getState()
if (!pages.has(pagePath)) {
throw new Error(
`Page "${pagePath}" doesn't exist. It might have been deleted recently.`
)
}
const query = queries.trackedQueries.get(pagePath)
if (!query) {
throw new Error(`Could not find query ${pagePath}`)
}
if (query.running !== 0) {
return waitNextPageData(pagePath, waitForMS, initialWaitForMs)
}
if (query.dirty !== 0) {
emitter.emit(`QUERY_RUN_REQUESTED`, { pagePath })
return waitNextPageData(pagePath, waitForMS, initialWaitForMs)
}
if (pendingPageDataWrites.pagePaths.has(pagePath)) {
return waitNextPageData(pagePath, waitForMS, initialWaitForMs)View on GitHub (pinned to 8b06340921)
Solutions
- Verify the path matches an actual created page (check createPage calls and the pages redux state).
- Handle the deletion race by re-fetching or falling back to a 404 page.
- Ensure createPage runs before client/dev requests hit that path.
Defensive patterns
Strategy: try-catch
Validate before calling
const { store } = require('gatsby/dist/redux')
function pageExists(pagePath) {
return store.getState().pages.has(pagePath)
} Type guard
function pageExistsInStore(state, pagePath) { return state.pages.has(pagePath) } Try / catch
try {
const data = await getPageData(pagePath)
} catch (err) {
if (/doesn't exist/.test(err.message)) { /* serve 404 or re-trigger createPage */ }
else throw err
} Prevention
- Validate pagePath against the pages store before requesting page-data.
- Handle deletion races in dev by falling back to a 404 page.
- Ensure createPage completes before advertising the route to clients.
When it happens
Trigger: Requesting page-data for a path with no corresponding createPage; client navigation to a page removed during HMR; SSR/dev request for a mistyped path.
Common situations: Page deleted between request and processing; wrong/typo path; createPage never called for that route; race during hot reload.
Related errors
- Could not find query ${pagePath}
- Page for "${pathName}" not found
- ${r.errors.join(`, `)}
- message?.context?.sourceMessage
- Pages can only be created by plugins. There wasn't a plugin
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/8727947f1ab78a9c.
Report an issue: GitHub.