gatsbyjs/gatsby · error · ExportIsNotAsyncError

BabelPluginRemoveGraphQLQueries: the "config" export must be

Error message

BabelPluginRemoveGraphQLQueries: the "config" export must be async when using it with graphql

What it means

isWithinConfigExport inspects an export named 'config' in a page/shadowable module used with graphql. Gatsby requires such a config export to be declared async (it may query GraphQL), so a synchronous `export function config` or `export const config =` form triggers ExportIsNotAsyncError at that location.

Source

Thrown at packages/babel-plugin-remove-graphql-queries/src/index.ts:620

        })
        tagsToRemoveImportsFrom.forEach(removeImport)
      },
    },
  }
}

function isWithinConfigExport(
  path: NodePath<TaggedTemplateExpression>
): boolean {
  const parentExport = path.findParent(parent =>
    parent.isExportNamedDeclaration()
  ) as NodePath<ExportNamedDeclaration> | null

  const declaration = parentExport?.node?.declaration

  if (isFunctionDeclaration(declaration) && declaration.id?.name === `config`) {
    if (!declaration.async) {
      throw new ExportIsNotAsyncError(`config`, declaration.loc?.start)
    }
    return true
  }
  if (
    isVariableDeclaration(declaration) &&
    isIdentifier(declaration.declarations[0]?.id) &&
    declaration.declarations[0]?.id?.name === `config`
  ) {
    const init = declaration.declarations[0]?.init
    if (!isFunction(init) || !init.async) {
      throw new ExportIsNotAsyncError(`config`, init?.loc?.start)
    }
    return true
  }
  return false
}

export {

View on GitHub (pinned to e85d62f177)

Solutions

  1. Make the config export async: `export async function config(args)`
  2. Keep graphql calls inside the async config function
  3. Restart the dev server or re-run build after fixing the export
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/babel-plugin-remove-graphql-queries/src/index.ts:620 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/2da6a6b6703798df. Report an issue: GitHub.