Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sidharthachatterjee opened this issue Jul 15, 2019 · 23 comments · Fixed by #16220
Labels
help wanted Issue with a clear description that the community can help with. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@sidharthachatterjee
Copy link
Contributor

sidharthachatterjee commented Jul 15, 2019

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

@sidharthachatterjee sidharthachatterjee added help wanted Issue with a clear description that the community can help with. topic: themes type: bug An issue or pull request relating to a bug in Gatsby labels Jul 15, 2019
@sidharthachatterjee sidharthachatterjee added this to To do in "Snow Leopard" fixes via automation Jul 15, 2019
@m-allanson
Copy link
Contributor

m-allanson commented Jul 15, 2019

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'

@eclectic-coding
Copy link
Contributor

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.

@sonapraneeth-a
Copy link
Contributor

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

@janosh
Copy link
Contributor

janosh commented Jul 22, 2019

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.

@janosh
Copy link
Contributor

janosh commented Jul 22, 2019

Could this be related to #15615?

@yurkoturskiy
Copy link
Contributor

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>
  )
}
...

@kogal
Copy link

kogal commented Jul 25, 2019

Same issue with client-only paths ('/app/*') using gatsby-plugin-create-client-paths@2.1.3

@ssijak
Copy link

ssijak commented Jul 29, 2019

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

@wardpeet
Copy link
Contributor

wardpeet commented Aug 1, 2019

Successfully published:

  • gatsby@2.13.46

@janosh
Copy link
Contributor

janosh commented Aug 1, 2019

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.

@prodeniser
Copy link

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

simonwiles added a commit to apilcs/website that referenced this issue Sep 30, 2019
This this might be a workaround for a bug in Gatsby: gatsbyjs/gatsby#15724
@yyyyaaa
Copy link

yyyyaaa commented Oct 13, 2019

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

@JR-Carroll
Copy link

JR-Carroll commented Feb 9, 2020

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).

simonwiles added a commit to apilcs/website that referenced this issue Feb 10, 2020
This this might be a workaround for a bug in Gatsby: gatsbyjs/gatsby#15724
@KishanMaurya
Copy link

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

Please help me, how can I solve this issue

@franva
Copy link

franva commented Aug 16, 2020

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

2 similar comments
@shanghaikid
Copy link

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

@soimyy
Copy link

soimyy commented Sep 13, 2020

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

@marcus13371337
Copy link

marcus13371337 commented Dec 10, 2020

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.

@barbalex
Copy link

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

@gnorg
Copy link

gnorg commented Oct 25, 2021

Hey peepz,
don't know if that helps someone, but I had the same Error loading a result for the page query in "/404.html", And that's with Gatsby v4.
My solution was to run gatsby clean and then to run gatsby build again.

@jaymarkjairi
Copy link

my problem is not solve in running gatsby clean. I am using "gatsby": "^4.11.2",

@dpw1
Copy link

dpw1 commented Aug 9, 2022

Any updates on this? gatsby clean doesn't solve my issue, nor any of the aforementioned suggestions. I'm using "gatsby": "^4.5.4"

Any ideas are greatly appreciated.

EDIT:

I managed to fix it. In my case it was a plugin breaking the 404 page. (gatsby-plugin-favicons).

If you experience this error, try removing the plugins you think that might be causing this issue.

@j127
Copy link
Contributor

j127 commented Mar 26, 2023

If anyone runs into this problem, make sure the Gatbsy server isn't running in a different terminal window. That's what the problem was in my case (March 2023).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with. type: bug An issue or pull request relating to a bug in Gatsby
Projects
No open projects
Development

Successfully merging a pull request may close this issue.