gatsby: Upgrade from gatsby@1.9.123 to gatsby@1.9.127 seemingly breaks JSON parsing when there's a significant amount of JSON

Preamble

Gatsby version: 1.9.127 node.js version: v8.9.1 OS version: Linux version 4.13.16-35.current (Solus OS)

gatsby-config.js

module.exports = {
  siteMetadata: {
    title: `someTitle`,
    buildID: '22166834-86c7-4c26-9770-afd9b2889e09'
  },
  plugins: [
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-styled-components`,
    `gatsby-plugin-react-next`,
  ],
  pathPrefix: '/e2fd2e20-0e66-4c28-b503-e841e8f04769'
}

package.json:

{
  "name": "someName"
  "description": "some landing pages"
  "version": "1.0.0",
  "author": ""
  "dependencies": {
    "gatsby": "^1.9.73",
    "gatsby-link": "^1.6.22",
    "gatsby-plugin-react-helmet": "^1.0.8",
    "gatsby-plugin-react-next": "^1.0.4",
    "moment": "^2.19.1",
    "query-string": "^5.0.1",
    "react-redux": "^5.0.6",
    "rebass": "^1.0.4",
    "redux": "^3.7.2",
    "uuid": "^3.1.0"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "main": "n/a",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --trailing-comma es5 --no-semi --single-quote --write 'src/**/*.js'",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "gatsby-plugin-styled-components": "^1.0.5",
    "prettier": "^1.7.4"
  }
}

The issue

In development mode, some pages with long JSON strings as variables throw this error before successfully recompiling (after which the pages can be successfully rendered in-browser):

$ gatsby develop
success delete html files from previous builds — 0.027 s
success open and validate gatsby-config.js — 0.004 s
success copy gatsby files — 0.013 s
success onPreBootstrap — 0.005 s
success source and transform nodes — 0.011 s
success building schema — 0.060 s
success createLayouts — 0.015 s
success createPages — 0.004 s
success createPagesStatefully — 0.146 s
success onPreExtractQueries — 0.001 s
success update schema — 0.054 s
success extract queries from components — 0.083 s
success run graphql queries — 0.034 s
success write out page data — 0.008 s
success write out redirect data — 0.000 s
success onPostBootstrap — 0.000 s
info bootstrap finished - 1.401 s
>  ERROR  Failed to compile with 2 errors                                                                                              18:40:46
 error  in ./.cache/json/district-8055.json
Syntax Error: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
 @ ./.cache/sync-requires.js 145:22837-22947
 error  in ./.cache/json/district-8056.json
Syntax Error: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
 @ ./.cache/sync-requires.js 145:23135-23245
 WAIT  Compiling...                                                                                                                  18:40:46
 DONE  Compiled successfully in 389ms

When trying to create the production build, this error is thrown, causing the whole build to fail:

$ gatsby build
success delete html files from previous builds — 0.030 s
success open and validate gatsby-config.js — 0.004 s
success copy gatsby files — 0.013 s
success onPreBootstrap — 0.007 s
success source and transform nodes — 0.013 s
success building schema — 0.090 s
success createLayouts — 0.018 s
success createPages — 0.001 s
success createPagesStatefully — 0.150 s
success onPreExtractQueries — 0.001 s
success update schema — 0.059 s
success extract queries from components — 0.041 s
success run graphql queries — 0.021 s
success write out page data — 0.006 s
success write out redirect data — 0.000 s
success onPostBootstrap — 0.000 s
info bootstrap finished - 1.342 s
success Building CSS — 4.001 s
success Building production JavaScript bundles — 11.812 s
error Building static HTML for pages failed
See our docs page on debugging HTML builds for help https://goo.gl/yL9lND
  Error: Module build failed: SyntaxError: Unexpected end of JSON input
  - JSON.parse
  - index.js:4 Object.module.exports
    [mobytrip-landing-pages]/[json-loader]/index.js:4:49
  - @ ./.cache/sync-requires.js 144:15387-15497
error Command failed with exit code 1.

Do let me know if you need more information or an example page itself to work with. Thanks in advance.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@healingfromjava lol what in the world are you doing? 660 sites? Glad it works though!

@KyleAMathews Just tested #3218 on 660 different sites spanning 56,275 pages. Works like a charm! Thanks again for the fix–we really appreciate it.

Should be fixed in #3218 lemme know if you’re still seeing troubles!