Gatsby: Error loading a result for the page query in "/404.html". Query was not run and Page not found /404.html

Created on 15 Jul 2019  路  19Comments  路  Source: gatsbyjs/gatsby

Description

When using gatsby develop with a theme, the following error is printed in the terminal after a page is loaded in the browser:

Error loading a result for the page query in "/404.html". Query was not run and
Page not found /404.html

Steps to reproduce

  • gatsby new my-blog gatsbyjs/gatsby-starter-blog-theme
  • cd my-blog
  • gatsby develop
  • browse to http://localhost:8000
  • check the terminal to see this message:
Error loading a result for the page query in "/404.html". Query was not run and no cached result was
Page not found /404.html
  • This message will be printed to the terminal every time the page is refreshed.

There's also a repro available at https://github.com/polishedwp/gatsby-starter-theme-eclectic courtesy of @polishedwp

Expected result

The _Error loading a result for the page query..._ message should not appear in the terminal.

Actual result

The message appears.

Environment


  System:
    OS: macOS 10.14.5
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Languages:
    Python: 3.5.3 - /Users/mike/.pyenv/shims/python
  Browsers:
    Chrome: 75.0.3770.100
    Firefox: 67.0.4
    Safari: 12.1.1
  npmPackages:
    gatsby: ^2.13.21 => 2.13.21 
    gatsby-theme-blog: ^1.0.0 => 1.0.0 
  npmGlobalPackages:
    gatsby-cli: 2.7.7
    gatsby-dev-cli: 2.4.19
    gatsby: 2.8.8

help wanted themes bug

Most helpful comment

For me the error persists. Running gatsby build still crashes with

ERROR #95313

Building static HTML failed for path "/404.html"

See our docs page for more info on this error: https://gatsby.dev/debug-html

Error: ENOENT: no such file or directory, open './public/page-data/404.html/page-data.json'

  • render-page.js:547 Module../.cache/static-entry.js.__webpack_exports__.default

As mentioned above, if I delete the cache, rm -r .cache, it builds fine but only once.

All 19 comments

Note that running gatsby build && gatsby serve will show the same error as error Error: ENOENT: no such file or directory, stat '/path/to/my/project/hello-world/public/404.html'

So, I installed each of the starters and the only starter that displays the 404 error in the terminal is the hello-world starter.

The 404 message appears in each of the default theme starters including the new workspace theme starter.

As per @jlengstorf , we need to have a 404.js in our site currently as 404 generation is not supported as of now.

I'm also getting this (or a very similar) error on gatsby build independently of themes:

ERROR ENOENT: no such file or directory, open '/<project-root>/public/page-data/404.html/page-data.json'

Running rm -r .cache solves the problem until the next build.

Could this be related to #15615?

Though everything works as it should, I'm getting the same error when navigating pages I'm routing with @reach/router and gatsby-plugin-create-client-paths
My console:

Error loading a result for the page query in "/authentication/navigate". Query was not run and no cached result was found.
Page not found /authentication/navigate
Error loading a result for the page query in "/authentication/login". Query was not run and no cached result was found.
Page not found /authentication/login

gatsby-config.js:

...
{
  resolve: `gatsby-plugin-create-client-paths`,
  options: {
  prefixes: [`/confirm-email/*`, `/authentication/*`],
},
...

My pages/authentication/index.js component:

...
const AuthenticationIndex = () => {
  return (
    <Layout>
      <div className="authentication-container">
        <Router>
          <Navigator path="authentication/navigate" />
          <AuthenticationContainer path="authentication" />
          <LoginFormContainer path="authentication/login" />
          <RegistrationFormContainer path="authentication/signup" />
          <PasswordResetFormContainer path="authentication/password-reset" />
          <PasswordResetConfirmFormContainer path="authentication/password-reset/confirm/:uid/:token" />
        </Router>
      </div>
    </Layout>
  )
}
...

Same issue with client-only paths ('/app/*') using [email protected]

I also have this printed out with the same setup as @kogal Everything seems to work OK, but those printouts bother me

Successfully published:

For me the error persists. Running gatsby build still crashes with

ERROR #95313

Building static HTML failed for path "/404.html"

See our docs page for more info on this error: https://gatsby.dev/debug-html

Error: ENOENT: no such file or directory, open './public/page-data/404.html/page-data.json'

  • render-page.js:547 Module../.cache/static-entry.js.__webpack_exports__.default

As mentioned above, if I delete the cache, rm -r .cache, it builds fine but only once.

Also having an issue. Only thing that has helped is by clearing the cache as @janosh mentioned

Any update on this? With the latest gatsby version I still have this issue, and it affects gatsby develop as well, which leads to hot loading not working

Not sure if anyone is still monitoring this thread, but I am occasionally getting this same (similar, but different) error.

As others have said, stopping gatsby develop and then rm -rf .cache fixes, but about every 3rd or 4th time of running gatsby develop I get this error, and if I don't catch it, it breaks production build pipelines...

Did anyone ever find a (more perm) solution for this situation?

edit nvm, I see that this issue is closed (after I posted), I'll see if I can find a more active/recent ticket).

Error: ENOENT: no such file or directory, stat 'D:\protfolio\kishan-portfolio\public\404.html'

Please help me, how can I solve this issue

hit the same issue here....... anyone has a solution?

hit the same issue here....... anyone has a solution?

hit the same issue here....... anyone has a solution?

I have the same issue initially when the serve-command is finished. We have approx ~22k pages and it seems as the develop command reports that it's finished before all the queries are ready to be consumed by the frontend. But if I leave it running for ~2 minutes everyting works

I've noticed that the /dev-404-page fetches ALL pages, which makes the result of that query very long. Is it needed to preload all pages in order to show the dev-404 page (with all pages listed). I mean we have a dev-server running which could use server-side pagination and search.

I am getting this now too - never noticed before. Just updated to "gatsby": "2.28.2"

Was this page helpful?
0 / 5 - 0 ratings