gatsbyjs/gatsby · error

There was an attempt to call a Preview onPageCreated callbac

Error message

There was an attempt to call a Preview onPageCreated callback for node ${nodeIdThatCreatedThisPage}, but no node was found.

What it means

In onCreatePageRespondToPreviewStatusQuery, a page was created whose context references a nodeIdThatCreatedThisPage with a registered preview onPageCreated callback, but getNode() can no longer find that node. This happens when the node was deleted or not yet created at page-creation time during a preview; the callback is skipped, so the WP editor may not receive a successful preview status for that node.

Source

Thrown at packages/gatsby-source-wordpress/src/steps/preview/on-create-page.ts:91

  const nodePageCreatedCallback =
    nodeIdThatCreatedThisPage &&
    nodePageCreatedCallbacks[nodeIdThatCreatedThisPage]

  if (
    !nodeIdThatCreatedThisPage ||
    typeof nodePageCreatedCallback !== `function`
  ) {
    return
  }

  getStore().dispatch.previewStore.unSubscribeToPagesCreatedFromNodeById({
    nodeId: nodeIdThatCreatedThisPage,
  })

  const nodeThatCreatedThisPage = getNode(nodeIdThatCreatedThisPage)

  if (!nodeThatCreatedThisPage) {
    helpers.reporter.warn(
      formatLogMessage(
        `There was an attempt to call a Preview onPageCreated callback for node ${nodeIdThatCreatedThisPage}, but no node was found.`
      )
    )
    return
  }

  // We need to add the modified time to pageContext so we can read it in WP
  // This way can tell when the updated page has been deployed
  if (!page.context.__wpGatsbyNodeModified) {
    const pageCopy = { ...page }
    pageCopy.context.__wpGatsbyNodeModified = nodeThatCreatedThisPage.modified

    const { deletePage, createPage } = helpers.actions

    deletePage(page)
    createPage(pageCopy)
  }

View on GitHub (pinned to e85d62f177)

Solutions

  1. Re-run/retry the preview so the node exists when the page is created.
  2. Ensure the previewed content still exists in WordPress and was not deleted mid-preview.
  3. Run gatsby clean && gatsby develop to rebuild node/page state from scratch.
  4. If reproducible, report to gatsby-source-wordpress — it may indicate a node/page creation ordering bug.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at packages/gatsby-source-wordpress/src/steps/preview/on-create-page.ts:91 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/f3673d5061684892. Report an issue: GitHub.