-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
gatsby build error: JSON.parse (from json-loader) #3148
Comments
This sounds like this could be the issue I'm seeing in #3139. |
I'm stumped. The closest I've gotten to narrowing this down is to insert a sleep function into My gut tells me its something to do with a (╯°□°)╯︵ ┻━┻ |
This bug was hard to track down as it manifested itself in a weird way. Gatsby tracks external changes which indicate a need to re-run GraphQL queries. Which is normally fine since Gatsby also is tracking which queries would be dirtied by the external change (e.g. a query depends on a file — when that file is changed, the query is "dirty" and needs run again). But pages/layouts *without* queries weren't being tracked which meant that on every external change, Gatsby would think it needed to run those queries again. During the build process. Gatsby assumes that external data won't change so during the bootstrap, it waits for the initials set of queries to finish running but during later stages, it doesn't. Because sites with lots of pages with no queries were running their queries over and over, this meant that occassionally webpack would try to load a JSON file (queries are written out as JSON files) that wasn't finished writing. This PR fixes the problem as now during build, Gatsby only attempts to run queries for page/layout components without queries during the initial bootstrap.
* Track pages/layouts without queries fixes #3139 #3148 #3094 This bug was hard to track down as it manifested itself in a weird way. Gatsby tracks external changes which indicate a need to re-run GraphQL queries. Which is normally fine since Gatsby also is tracking which queries would be dirtied by the external change (e.g. a query depends on a file — when that file is changed, the query is "dirty" and needs run again). But pages/layouts *without* queries weren't being tracked which meant that on every external change, Gatsby would think it needed to run those queries again. During the build process. Gatsby assumes that external data won't change so during the bootstrap, it waits for the initials set of queries to finish running but during later stages, it doesn't. Because sites with lots of pages with no queries were running their queries over and over, this meant that occassionally webpack would try to load a JSON file (queries are written out as JSON files) that wasn't finished writing. This PR fixes the problem as now during build, Gatsby only attempts to run queries for page/layout components without queries during the initial bootstrap. * Fix formatting
Should be fixed in #3218 lemme know if you're still seeing troubles! |
@alampros thanks so much for your reproduction site! It was perfect for debugging what was going on ❤️ |
Occurs when a large number of pages (~20-50) are generated via
gatsby-node.js#createPage
. Works fine when only a handful are generated using the same method.I've created a repo to reproduce this error: https://github.com/alampros/gatsby-json-parse-bug
error Building static HTML for pages failed
The text was updated successfully, but these errors were encountered: