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

Description

Trying to run gatsby dev on heroku to use as a custom preview instance. This worked very well in the past.

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

This seems to be an issue with recent versions of gatsby (^2.18 or so, can’t be exact here), since I have an instance running fine on the same environment which shows gatsby@2.13.35 as the installed version, with npm list gatsby.

Steps to reproduce

  1. gatsby new test-gatsby-site
  2. cd test-gatsby-site
  3. add Procfile with web: gatsby develop -p $PORT -H 0.0.0.0
  4. heroku create test-gatsby-site
  5. heroku config:set NODE_ENV=development
  6. heroku config:set NPM_CONFIG_PRODUCTION=false
  7. commit everything in git
  8. git push heroku master
  9. after deploying, which goes fine, open the ap url (test-gatsby-site.herokuapp.com)

Non-working example

Actual example showing the error running at: https://gatsby-plain-test.herokuapp.com/ (give it a minute for the dyno to spin up first, if the page is taking too long too load - it’s just asleep as a free dyno)

Working example

As proof that it can work, I’ve set up another heroku instance with gatsby@2.13.35 which works just fine https://gatsby-plain-testt.herokuapp.com/ The only thing I did was to downgrade the gatsby and corresponding packages versions (react, react-dom, etc)

Expected result

The index page should render.

Actual result

gatsby-error

console shows 3 sets of this type of error, originating from:

index.js:2177 The above error occurred in the <Layout> component:
    in Layout (at pages/index.js:9)
    in IndexPage (created by HotExportedIndexPage)
    in AppContainer (created by HotExportedIndexPage)
    in HotExportedIndexPage (created by PageRenderer)
    in PageRenderer (at query-result-store.js:86)
    in PageQueryStore (at root.js:51)
    in RouteHandler (at root.js:73)
    in div (created by FocusHandlerImpl)
    in FocusHandlerImpl (created by Context.Consumer)
    in FocusHandler (created by RouterImpl)
    in RouterImpl (created by Context.Consumer)
    in Location (created by Context.Consumer)
    in Router (created by EnsureResources)
    in ScrollContext (at root.js:64)
    in RouteUpdates (at root.js:63)
    in EnsureResources (at root.js:61)
    in LocationHandler (at root.js:119)
    in LocationProvider (created by Context.Consumer)
    in Location (at root.js:118)
    in Root (at root.js:127)
    in StaticQueryStore (at root.js:133)
    in _default (at app.js:67)
index.js:2177 The above error occurred in the <AppContainer> component:
    in AppContainer (created by HotExportedIndexPage)
    in HotExportedIndexPage (created by PageRenderer)
    in PageRenderer (at query-result-store.js:86)
    in PageQueryStore (at root.js:51)
    in RouteHandler (at root.js:73)
    in div (created by FocusHandlerImpl)
    in FocusHandlerImpl (created by Context.Consumer)
    in FocusHandler (created by RouterImpl)
    in RouterImpl (created by Context.Consumer)
    in Location (created by Context.Consumer)
    in Router (created by EnsureResources)
    in ScrollContext (at root.js:64)
    in RouteUpdates (at root.js:63)
    in EnsureResources (at root.js:61)
    in LocationHandler (at root.js:119)
    in LocationProvider (created by Context.Consumer)
    in Location (at root.js:118)
    in Root (at root.js:127)
    in StaticQueryStore (at root.js:133)
    in _default (at app.js:67)
The above error occurred in the <LocationProvider> component:
    in LocationProvider (created by Context.Consumer)
    in Location (at root.js:118)
    in Root (at root.js:127)
    in StaticQueryStore (at root.js:133)
    in _default (at app.js:67)

Environment

Run gatsby info --clipboard

Non-Working example (https://gatsby-plain-test.herokuapp.com/ ) env info:

  System:
    OS: Linux 4.4 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 12.16.0 - ~/.heroku/node/bin/node
    Yarn: 1.22.0 - ~/.heroku/yarn/bin/yarn
    npm: 6.13.4 - ~/.heroku/node/bin/npm
  Languages:
    Python: 2.7.17 - /usr/bin/python
  npmPackages:
    gatsby: ^2.19.7 => 2.19.7
    gatsby-image: ^2.2.39 => 2.2.39
    gatsby-plugin-react-helmet: ^3.1.21 => 3.1.21
    gatsby-plugin-sharp: ^2.4.3 => 2.4.3
    gatsby-source-filesystem: ^2.1.46 => 2.1.46
    gatsby-transformer-sharp: ^2.3.13 => 2.3.13

Also react:

    "react": "^16.12.0",
    "react-dom": "^16.12.0",

Working example (https://gatsby-plain-testt.herokuapp.com/ ) env info

System:
    OS: Linux 4.4 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 12.16.0 - ~/.heroku/node/bin/node
    npm: 6.13.4 - ~/.heroku/node/bin/npm
  Languages:
    Python: 2.7.17 - /usr/bin/python
  npmPackages:
    gatsby: 2.13.35 => 2.13.35
    gatsby-image: ^2.0.41 => 2.2.40
    gatsby-plugin-react-helmet: ^3.0.12 => 3.1.22
    gatsby-plugin-sharp: ^2.3.2 => 2.4.5
    gatsby-source-filesystem: ^2.1.38 => 2.1.48
    gatsby-transformer-sharp: ^2.3.5 => 2.3.14

Also react:

    "react": "^16.8.6",
    "react-dom": "^16.8.6",

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 28 (10 by maintainers)

Most upvoted comments

This is getting a serious issue!

I pushed a commit to GitHub today just doing some changes to readme and nothing else. And my production broke showing a white screen to all users.

It still shows the same error message:

https://i.imgur.com/7tsLRCk.png

But don’t know:

  • how this is true just for production and not in deployment?
  • if its true how until my last commit it was working properly and broke after doing simple readme changes?

Also I mentioned about this on yet another closed issue yesterday, #13764 .

I hope this gets some attention.

Edit1: I’m deploying via Vercel.

Edit 2: Live demo link (https://wirescript-n8hi8iya9.vercel.app/).

Check console in dev tools

This is the preview link for the readme update commit I talked about above. But now it works after doing a re-deployment.

It should be reproducible by exactly the steps OP has described. Last tested it around 7 days ago and that issue still exists. However, please keep in mind that this issue only appears on Heroku.

Hey there! This is still an issue. It’s also worth noting that this approach is specifically recommended in the Gatsby docs on how to run a custom preview instance on Heroku, so I really think this should be looked into.

The following reproduction is a simple Gatsby starter (gatsby-starter-hello-world) with a static query for siteMetadata and a Procfile for Heroku.

Here’s the reproduction: https://github.com/woodwoerk/heroku-gatsby-dev-bug-repro.git

@freiksenet @LekoArts could this please be reopened? ❤️

I can also confirm this bug



  System:
    OS: macOS 10.15.3
    CPU: (4) x64 Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.9.1 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.12.0 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 80.0.3987.116
    Firefox: 67.0.4
    Safari: 13.0.5
  npmPackages:
    gatsby: ^2.19.16 => 2.19.16 
    gatsby-image: ^2.2.40 => 2.2.40 
    gatsby-plugin-compile-es6-packages: ^1.1.0 => 1.2.0 
    gatsby-plugin-eslint: ^2.0.5 => 2.0.8 
    gatsby-plugin-google-tagmanager: ^2.1.25 => 2.1.25 
    gatsby-plugin-hubspot: ^1.3.3 => 1.3.3 
    gatsby-plugin-manifest: ^2.2.41 => 2.2.41 
    gatsby-plugin-offline: ^2.2.0 => 2.2.10 
    gatsby-plugin-page-creator: ^2.1.40 => 2.1.40 
    gatsby-plugin-react-helmet: ^3.1.22 => 3.1.22 
    gatsby-plugin-react-helmet-canonical-urls: ^1.2.0 => 1.4.0 
    gatsby-plugin-robots-txt: ^1.5.0 => 1.5.0 
    gatsby-plugin-sharp: ^2.4.5 => 2.4.5 
    gatsby-plugin-sitemap: ^2.2.27 => 2.2.27 
    gatsby-plugin-styled-components: ^3.1.19 => 3.1.19 
    gatsby-plugin-webpack-bundle-analyser-v2: ^1.1.8 => 1.1.8 
    gatsby-source-datocms: ^2.1.23 => 2.1.23 
    gatsby-source-filesystem: ^2.1.48 => 2.1.48 
    gatsby-transformer-react-docgen: ^5.0.29 => 5.0.29 
    gatsby-transformer-sharp: ^2.3.14 => 2.3.14 
  npmGlobalPackages:
    gatsby-cli: 2.8.19