question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES is broken for static queries

See original GitHub issue

Description

When running gatsby build with GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true, an error is thrown if anything is using useStaticQuery.

Sample error:

Can't resolve '../../public/static/d/856328897.json' in '/path/to/src/components

Steps to reproduce

Sample project (which is just a project initialized with gatsby new: https://github.com/TAGraves/gatsby-incremental-example

First, run:

GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true yarn gatsby build --log-pages

which should output

info Built pages:
Updated page: /404/
Updated page: /
Updated page: /page-2/
Updated page: /404.html

Then, remove everything from .cache and public other than .cache/redux:

rm -r public
cd .cache && ls | grep -v redux | xargs
cd ../

Then run gatsby build again:

GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true yarn gatsby build --log-pages 

Expected result

gatsby build should complete showing no new, updated, or deleted pages.

Actual result

gatsby build fails with an error like

Can't resolve '../../public/static/d/856328897.json' in '/path/to/src/components

Environment

  System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.14.0 - /var/folders/xh/kxyylf2j2k51pw11htddhb9c0000gn/T/yarn--1585491262407-0.3432572041341917/node
    Yarn: 1.12.3 - /var/folders/xh/kxyylf2j2k51pw11htddhb9c0000gn/T/yarn--1585491262407-0.3432572041341917/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.14.0/bin/npm
  Languages:
    Python: 2.7.16 - /Users/tommygraves/.pyenv/shims/python
  Browsers:
    Chrome: 80.0.3987.149
    Firefox: 74.0
    Safari: 13.0.5
  npmPackages:
    gatsby: ^2.19.45 => 2.19.45
    gatsby-image: ^2.2.44 => 2.2.44
    gatsby-plugin-manifest: ^2.2.48 => 2.2.48
    gatsby-plugin-offline: ^3.0.41 => 3.0.41
    gatsby-plugin-react-helmet: ^3.1.24 => 3.1.24
    gatsby-plugin-sharp: ^2.4.13 => 2.4.13
    gatsby-source-filesystem: ^2.1.56 => 2.1.56
    gatsby-transformer-sharp: ^2.3.19 => 2.3.19

If you remove all the static queries from the components, the command runs successfully and has the expected behavior.

Tagging @dominicfallows since they built this feature. I do wonder if this is related to https://github.com/gatsbyjs/gatsby/pull/21555 since the PR and documentation around GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES mention the old redux.state file rather than the new redux directory. Thanks friends!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
vladarcommented, Apr 1, 2020

CC @pieh

0reactions
TAGravescommented, Apr 1, 2020

Thanks for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Common Errors - Gatsby
If the error is describing an Unknown field 'X' on type 'Query' , the content type you are trying to source is likely...
Read more >
Gatsby Changelog | 5.3.0
Fix writing of static query files when automatic sort and aggregation graphql codemod is run, ... Install experimental version of react and react-dom...
Read more >
An Honest Review of Gatsby - Hacker News
Once a static page is produced, we can store it for usage across the entire ... because the design of this data layer...
Read more >
Gatsby - The result of this StaticQuery could not be fetched
Reason for script "storybook:static-query" thanks to mohsenkhanpour. But in short the "babel-plugin-remove-graphql-queries" look for the queries ...
Read more >
Getting Started with Gatsby: Build Your First Static Site
Gatsby is also built with GraphQL, so you can query data and display it on your website any way you want. Installing Gatsby...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found