Gatsby build Error: Error loading a result for the page query in "[path]". Query was not run and no cached result was found

Hi, I’m experiencing a new deployment issue that started on Friday with a client’s site.

When I push an update to Github or when the client triggers deployment via build hook within their CMS, we get this error every time:

Gatsby build Error: Error loading a result for the page query in "[path]". Query was not run and no cached result was found.

If I “Clear cache and retry with latest branch commit”, the build is successful.

I cannot reproduce the issue locally using netlify build. The build succeeds every time locally.

Any and all ideas welcome!

Thanks

Hi there,

Thanks for getting in touch! Can you let us know if the builds are failing on the same [path] each time or if the paths are different?

If it’s the same path, do you see any errors when navigating to that path in local development mode (gatsby develop)?

It would also be helpful to know if any package/version updates were made around the time you started noticing these errors. Looking forward to hearing from you!

Hi Marcus, the path seems to be arbitrary — it’s usually “/preview” which is a client only route used for Sanity draft previews. When I remove that route entirely, the path switches to a random product collection.

I don’t see any errors in the paths mentioned in when running gatsby develop locally.

There were no changes to the code base or dependencies when the issue started last Friday or since. The only changes possible would be on the content side coming from Sanity.

What’s strange is that the “clear cache and retry with latest branch commit” succeeds every time.

As an experiment, I tried deploying the same repo/branch to Vercel, and then tried redeploying several times via build hook and the deploys all succeeded with no errors.

Thanks for your help!

Thanks for following up and letting me know! Are you by chance using gatsby-plugin-create-client-paths to handle those client-only routes?

I ask because we’ve seen recent reports in the helpdesk of identical errors related to paths created by that plugin (which is deprecated and not compatible with recent versions of Gatsby).

If so, we’d recommend using the native approach for handling these routes (via the /app/[...].js file) and removing that plugin to see whether the errors persist. Thanks again!

Hi Marcus,

I am having the exact same issue on my client site. The path varies each time.

The issue does not show locally, or with a npm run build. I also have DEV_SSR set to true in my gatsby-config file.

Any idea on a route cause or time to fix on this issue?

In my instance I can confirm that we are definitely not using gatsby-plugin-create-client-paths anywhere in our project if that helps

Thanks for following up and letting us know - are the paths you’re having issues with also client-only paths (even if you’re not creating them using gatsby-plugin-create-client-paths ? A minimal reproduction of the errors you’re seeing (even if only replicable on Netlify) would go a long way in helping us identify any potential bugs as well as the next best steps!

I am actually using gatsby-plugin-create-client-paths on our main branch but I removed it and converted the client only route on test branch and experienced the same deploy error.

I’ve also been experiencing the same issue, and it’s specifically related to Gatsby’s matchPath, e.g.:

    createPage({
      path: `/search`,
      matchPath: `/search/*`,
      component: componentPath,
    })

Error:

error UNHANDLED REJECTION ENOENT: no such file or directory, open "/opt/build/repo/public/search/index.html"
Error: ENOENT: no such file or directory, open "/opt/build/repo/public/search/index.html"

It worked fine up until this week basically. Only the issue on Netlify (unless building with cache cleared), works fine elsewhere.

1 Like

Interesting! I’m also using matchPath for my collection pages, which is where I see the error if I remove the client only /preview route.

As mentioned above, we’re still waiting for:

Thank you for following up and providing this info! That definitely helps to narrow things down, although a minimal repo would still be ideal, as we’ve been running some tests with matchPath on our end (similar to @osvaldas above example) and haven’t yet been able to replicate this error on Netlify, e.g:

    createPage({
      path: "/search",
      matchPath: "/search/*",
      component: require.resolve("./src/components/search.js"),
    })   

I’m experiencing the exact same thing. Here’s a minimal repro:

You can see it’s pretty bare bones, no source plugins, no other libraries.

Steps to reproduce:

  1. netlify build locally (works)
  2. Link repo to netlify using netlify init
  3. First build (no cache) succeeds: Netlify App
  4. Second build (cached, triggered by netlify UI), succeeds: Netlify App
  5. Third build (cached, triggered by webhook), fails: Netlify App
2 Likes

Hi Ardie,

Thanks for sending this over! We’re passing this along to our Frameworks team for help getting to the bottom of this one, and we’ll be sure to follow up here with additional updates.

Hey all,

Our team has shipped some fixes for this here, and we’ve confirmed the fix on a clone of the above netlify-gatsby-matchPath-minimal-repro. Please let me know if you’re still seeing any issues!

1 Like