gatsbyjs/gatsby · error

Action createPage was called outside of its expected asynchr

Error message

Action createPage was called outside of its expected asynchronous lifecycle createPages in ${plugin.name}.
Ensure that you return a Promise from createPages and are awaiting any asynchronous method invocations (like graphql or http requests).
For more info and debugging tips: see https://gatsby.dev/sync-actions

What it means

Error "Action createPage was called outside of its expected asynchronous lifecycle createPages in ${plugin.name}. Ensure that you return a Promise from createPages and are awaiting any asynchronous method invocations (like graphql or http requests). For more info and debugging tips: see https://gatsby.dev/sync-actions" thrown in gatsbyjs/gatsby.

Source

Thrown at packages/gatsby/src/utils/api-runner-node.js:416

                `createPages`
              )} in ${chalk.bold(plugin.name)}.
              Ensure that you return a Promise from ${chalk.bold(
                `createPages`
              )} and are awaiting any asynchronous method invocations (like ${chalk.bold(
                `graphql`
              )} or http requests).
              For more info and debugging tips: see ${chalk.bold(
                `https://gatsby.dev/sync-actions`
              )}
            `),
            ]

            const possiblyCodeFrame = getNonGatsbyCodeFrameFormatted()
            if (possiblyCodeFrame) {
              warning.push(possiblyCodeFrame)
            }

            reporter.warn(warning.join(`\n\n`))
            alreadyDisplayed = true
          }
        },
      }
    }

    const localReporter = getLocalReporter({ activity, reporter })

    const runningActivities = new Set()

    const extendedLocalReporter = extendLocalReporterToCatchPluginErrors({
      reporter: localReporter,
      pluginName: plugin.name,
      runningActivities,
    })

    const endInProgressActivitiesCreatedByThisRun = () => {
      runningActivities.forEach(activity => activity.end())

View on GitHub (pinned to e85d62f177)

Solutions

  1. Return a Promise from createPages and await all graphql calls and async work before returning
  2. Ensure createPage/createPages actions are not called from un-awaited promises or setTimeout callbacks
  3. Use https://gatsby.dev/sync-actions debugging tips to locate the offending call site
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/gatsby/src/utils/api-runner-node.js:416 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/c19dd4c4bbc78c04. Report an issue: GitHub.