Gatsby: Error: The result of this StaticQuery could not be fetched.

Created on 10 Jun 2020  Β·  28Comments  Β·  Source: gatsbyjs/gatsby

Error: The result of this StaticQuery could not be fetched.

This is likely a bug in Gatsby and if refreshing the page does not fix it, please open an issue in https://github.com/gatsbyjs/gatsby/issues
useStaticQuery
C:/Users/fadhl/Desktop/projects/Gatsby/.cache/gatsby-browser-entry.js:76
73 | if (context[query] && context[query].data) {
74 | return context[query].data
75 | } else {

76 | throw new Error(
77 | The result of this StaticQuery could not be fetched.\n\n +
78 | This is likely a bug in Gatsby and if refreshing the page does not fix it, +
79 | please open an issue in https://github.com/gatsbyjs/gatsby/issues
View compiled
Layout
C:/Users/fadhl/Desktop/projects/Gatsby/src/components/layout.js:16
13 | import "./layout.css"
14 |
15 | const Layout = ({ children }) => {
16 | const data = useStaticQuery(graphql 17 | query SiteTitleQuery { 18 | site { 19 | siteMetadata { View compiled β–Ά 17 stack frames were collapsed. (anonymous function) C:/Users/fadhl/Desktop/projects/Gatsby/.cache/app.js:94 91 | const preferDefault = m => (m && m.default) || m 92 | let Root = preferDefault(require(./root)) 93 | domReady(() => { 94 | renderer(<Root />, rootElement, () => { 95 | apiRunner(onInitialClientRender`)
96 | })
97 | })

bug

Most helpful comment

I got 2.23.3 working after verifying 2.23.0, 2.23.1 & 2.23.2.

Here are the steps I took:

npm uninstall gatsby
rm -rf node_modules
add "gatsby": "2.23.3", to dependencies in package.json
npm install
gatsby develop

Then I updated each of the other outdated packages without error.

All 28 comments

Can you share more information about how you're using StaticQuery? Please provide a minimal reproduction.

Same error on multiple Gatsby projects after updating packages. Just created a new gatsby-starter-default to test what could be going wrong and ran gatsby develop with no error. After updating the following packages (all default, no new packages added), same StaticQuery error hits this new project.

Updated packages on the new project:

gatsby ^2.22.15 β†’ ^2.23.3
gatsby-image ^2.4.5 β†’ ^2.4.7
gatsby-plugin-manifest ^2.4.9 β†’ ^2.4.11
gatsby-plugin-offline ^3.2.7 β†’ ^3.2.9
gatsby-plugin-react-helmet ^3.3.2 β†’ ^3.3.4
gatsby-plugin-sharp ^2.6.9 β†’ ^2.6.11
gatsby-source-filesystem ^2.3.8 β†’ ^2.3.11
gatsby-transformer-sharp ^2.5.3 β†’ ^2.5.5
react ^16.12.0 β†’ ^16.13.1
react-dom ^16.12.0 β†’ ^16.13.1
react-helmet ^6.0.0 β†’ ^6.1.0

Now downgrading one by one to narrow down the cause.

I also updated packages and started getting this error.

I got 2.23.3 working after verifying 2.23.0, 2.23.1 & 2.23.2.

Here are the steps I took:

npm uninstall gatsby
rm -rf node_modules
add "gatsby": "2.23.3", to dependencies in package.json
npm install
gatsby develop

Then I updated each of the other outdated packages without error.

Think u

Le mer. 10 juin 2020 Γ  21:46, Geoff Carr notifications@github.com a
Γ©crit :

I also updated packages and started getting this error.

β€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/24902#issuecomment-642248472,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AO2LQYL7ITE7XMCHRBMSI23RV7WLDANCNFSM4N2IKZSQ
.

I got 2.23.3 working after verifying 2.23.0, 2.23.1 & 2.23.2.

Here are the steps I took:

npm uninstall gatsby
rm -rf node_modules
add "gatsby": "2.23.3", to dependencies in package.json
npm install
gatsby develop

Then I updated each of the other outdated packages without error.

Thanks, I just deleted my node_modules folder and ran npm install again. That seemed to do the trick.

Same problem. It seems to happen as soon as a plugin is installed

How to reproduce:

  1. gatsby new gatsby-site
  2. npm install --save gatsby-source-graphql (I have try with two diferent plugins, same result)
  3. npm i
    Then the error appears

Versions

Package.json

  "dependencies": {
    "gatsby": "^2.22.15",
    "gatsby-image": "^2.4.5",
    "gatsby-plugin-manifest": "^2.4.9",
    "gatsby-plugin-offline": "^3.2.7",
    "gatsby-plugin-react-helmet": "^3.3.2",
    "gatsby-plugin-sharp": "^2.6.9",
    "gatsby-source-filesystem": "^2.3.8",
    "gatsby-source-strapi": "0.0.12",
    "gatsby-transformer-sharp": "^2.5.3",
    "prop-types": "^15.7.2",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-helmet": "^6.0.0"
  },

NodeJS

v14.0.0 and v12.18.0 (tried both, same result)

OS

MacOS Catalina 10.15.5 (updated this week, already had some troubles with npm because of xcode but fixed them)

I also confirm both the issue and the fix by deleting node_modules and running npm ci.

My repro scenario:

  1. Everything works on [email protected]
  2. Renovate updates to [email protected] on remote master
  3. CI/CD triggers a new build of an app and it works
  4. I pull these changes to my dev machine
  5. I run npm ci
  6. I run npm start - an error appears

So, to fix this I need to remove node_modules before running npm ci.
Also, now it is clear why CI/CD executed without issues - there are new images for every build, so there are no old node_modules.

Facing the same issue, the above solutions didn't seem to work though.

Same happened to me, removing node_modules solved it.

I got 2.23.3 working after verifying 2.23.0, 2.23.1 & 2.23.2.

Here are the steps I took:

npm uninstall gatsby
rm -rf node_modules
add "gatsby": "2.23.3", to dependencies in package.json
npm install
gatsby develop

Then I updated each of the other outdated packages without error.

Thanks! Had the same issue after the latest update, and your solution worked as a charm for me.

This is a duplicate of https://github.com/gatsbyjs/gatsby/issues/24890

If you're encountering this issue locally, remove the node_modules folder and re-install. If you're encountering this e.g. on Netlify, run a Clean cache & build step.

The reason is a falsy node_modules/.cache state.

This is a duplicate of #24902

If you're encountering this issue locally, remove the node_modules folder and re-install. If you're encountering this e.g. on Netlify, run a Clean cache & build step.

The reason is a falsy node_modules/.cache state.

A duplicate of itself?

The problems comes with Google Chrome. With Firefox, its running fine. I am not sure what could be the problem. I tried clearing browsers cache but didn't work! Now I'm stuck!

I'm facing this same issue now.

@mdx-js/mdx": "^1.5.1",
    "@mdx-js/react": "^1.5.1",
    "babel-plugin-styled-components": "^1.10.0",
    "gatsby": "^2.23.23",
    "gatsby-image": "^2.0.39",
    "gatsby-plugin-feed-mdx": "^1.0.0",
    "gatsby-plugin-google-analytics": "^2.0.18",
    "gatsby-plugin-manifest": "^2.0.29",
    "gatsby-plugin-mdx": "^1.2.14",
    "gatsby-plugin-netlify-cms": "^4.3.7",
    "gatsby-plugin-offline": "^2.0.25",
    "gatsby-plugin-react-helmet": "^3.0.12",
    "gatsby-plugin-sharp": "^2.0.35",
    "gatsby-plugin-styled-components": "^3.0.7",
    "gatsby-plugin-typography": "^2.2.13",
    "gatsby-remark-copy-linked-files": "^2.0.11",
    "gatsby-remark-images": "^3.3.9",
    "gatsby-remark-responsive-iframe": "^2.1.1",
    "gatsby-remark-smartypants": "^2.0.9",
    "gatsby-remark-vscode": "^2.1.2",
    "gatsby-source-filesystem": "^2.0.29",
    "gatsby-transformer-sharp": "^2.1.18",
    "netlify-cms-app": "^2.9.1",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-helmet": "^5.2.0",
    "react-switch": "^5.0.0",
    "react-typography": "^0.16.19",
    "styled-components": "^4.2.0",
    "typeface-merriweather": "0.0.72",
    "typeface-montserrat": "0.0.54",
    "typography": "^0.16.19",
    "typography-theme-wordpress-2016": "^0.16.19"

Ok solved after several attempts. Gatsby clean. Then remove all node_modules and reinstall.

wtf I am only starting to use Gatsby for the second day and already had to do gatsby clean, remove all node_modules and reinstall 2 times and restart more than 5 times. This is crazy.....

@nickgrealy Please refrain from using such images, as per our Code of Conduct we want to create an inclusive & safe space and posting such images can certainly trigger some people.

@LekoArts - of course, deleted.

I'm still having this issue. I've added deleting node_modules and running gatsby clean to my deploy pipeline but I still get this error intermittently. I'm using the latest version of gatsby

Same error working with strapi.

I check on localhost:8000__graphql my query and it's fetching properly

But when I'm trying to use it on useStaticQuery(ARTICLES) displays Error: The result of this StaticQuery could not be fetched.

const ARTICLES = graphql`
  query Article {
    strapiArticle {
      id
      title
      content
      imageUrl
    }
  }
`;

Same error, on GraphiQL fetches fine, but on localhost shows Error: The result of this StaticQuery could not be fetched.

BUT it only shows up when using title or description, and it works perfectly with author.

Any ideas as to why?

const data = useStaticQuery(graphql
query {
site {
siteMetadata {
title
}
}
}
);

``

thank you, the first solution worked for me.

Hi, I'm new in Gatsby but I wanted to leave my humble solution.
1) Run command prompt Node.js as administrator
2) uninstall gatsby
3) npm install -g gatsby-cli
4) gatsby new yourSite
5) cd yourSite
6) gatsby develop

Running the cmd as Administrator solves incompatibilities.
-I wish the Info is useful-
Atte => { &Minin }

Hi, I'm new in Gatsby but I wanted to leave my humble solution.
1) Run command prompt Node.js as administrator
2) uninstall gatsby
3) npm install -g gatsby-cli
4) gatsby new yourSite
5) cd yourSite
6) gatsby develop

Running the cmd as Administrator solves incompatibilities.
-I wish the Info is useful-
Atte => { &Minin }

This will screw up git repo. Since you are moving it around or starting from the begging. Instead of moving directory around, deleting the node_modules, lock file and global gatsby followed by reinstall should do the trick. Unfortunately, I can't test it since I can't reproduce :/

I have also recently started to experience this issue as people are reporting. I have a 2 year old build which we have not experienced this until about a month a go. We are experiencing it on production only builds which really stinks when you have service workers that cache that experience for people and the average person would not go into their applications tab and restart their service worker :/

Started with Gatsby a few days ago. Changed the Windows PC, installed Gatsby, cloned the project.
Failed with 2.26.1 & 2.27.1.

Figured out that it was related to a single case sensitive filename.

I could reproduce it with gatsby-starter-default

Added gatsby-plugin-layout, i18next, i18next-browser-languagedetector and react-i18next.

Demo: https://github.com/Xairoo/my-gatsby-project

Just change src\components\Layout.js to src\components\layout.js and vice versa.

In my case, it seems like gatsby-plugin-graphql-codegen causes this problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3CordGuy picture 3CordGuy  Β·  3Comments

rossPatton picture rossPatton  Β·  3Comments

theduke picture theduke  Β·  3Comments

brandonmp picture brandonmp  Β·  3Comments

benstr picture benstr  Β·  3Comments