👋 Next.js Conf 2024: Come build, party, run, and connect with us! See all events

Gatsby site crashing with cryptic error, resolved by adjusting resolveReferences depth

2 replies
Last updated: Aug 18, 2020
a gatsby site I’m working on started crashing this morning, which is weird since no code has been changed between today and yesterday and the site worked fine yesterday.
I’m getting a cryptic error stating

 ERROR 

dbb54862-d17c-4e11-a1f0-701364e617ac


 ERROR 

Invalid string length



  RangeError: Invalid string length
  
  - JSON.stringify
  
  - query-runner.js:130 queryRunner
    [web]/[gatsby]/dist/query/query-runner.js:130:27
  
  - task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5
  
  - task_queues.js:66 runNextTicks
    internal/process/task_queues.js:66:3
  
  - timers.js:429 processImmediate
    internal/timers.js:429:9
  


 ERROR 

UNHANDLED REJECTION Cannot read property 'sourceMessage' of undefined



  TypeError: Cannot read property 'sourceMessage' of undefined
  
I tried to find a sanity document matching that ID through sanity cli but it could not find any documents matching that ID. I have no idea where the error is so any tips are appriciated! Full error in comments


➜  studio git:(master) sanity documents get dbb54862-d17c-4e11-a1f0-701364e617ac
Error: Failed to fetch document:
Document not found
Aug 18, 2020, 8:51 AM
➜  web git:(master) gatsby build
success open and validate gatsby-configs - 0.030s
success load plugins - 1.111s
success onPreInit - 0.014s
success delete html and css files from previous builds - 0.017s
success initialize cache - 0.006s
success copy gatsby files - 0.055s
warn [sanity] Using `watchMode` when not in develop mode might prevent your build from completing
info [sanity] Fetching remote GraphQL schema
info [sanity] Transforming to Gatsby-compatible GraphQL SDL
info [sanity] Stitching GraphQL schemas from SDL
success onPreBootstrap - 0.274s
success createSchemaCustomization - 0.011s
info [sanity] Fetching export stream for dataset
warn [sanity] Document "032bcc84-a29f-43e7-813a-9891b518c073" has type defaultPage (SanityDefaultPage), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "14eb51af-b637-49ff-acec-57e79decde73" has type defaultPage (SanityDefaultPage), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "2d180332-eaeb-46d6-acfd-1f32162b9255" has type subPages (SanitySubPages), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "2fbbb9a2-96e6-49f3-9e9d-684a42fca7d8" has type subPages (SanitySubPages), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "3ad3469a-a80a-4368-a17a-682bc30d2006" has type subPages (SanitySubPages), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "474ff26d-60f3-4695-958a-bd4b4df581d6" has type seo (SanitySeo), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "58448333-f086-4991-be69-ba38141e7316" has type defaultPage (SanityDefaultPage), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "616066c8-a50b-4bc5-a0ba-1a1661c148a9" has type frontPage (SanityFrontPage), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "76e070d6-2423-48b3-b83c-73ee8412e713" has type projects (SanityProjects), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "78df9b1e-92d3-4914-a54e-493c241f793f" has type defaultPage (SanityDefaultPage), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "7e2bdbf3-f8cb-416d-9c16-2238775b526c" has type defaultPage (SanityDefaultPage), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "8cf47c47-9442-466a-841c-051f4b3a1023" has type defaultPage (SanityDefaultPage), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "dbda5458-b53f-48a2-b7df-343e665405c6" has type projects (SanityProjects), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
warn [sanity] Document "e1bea075-bfe3-431d-a404-a466127606d7" has type projects (SanityProjects), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
info [sanity] Overlaying drafts
info [sanity] Watch mode enabled, starting a listener
info [sanity] Done exporting!
success source and transform nodes - 0.309s
warn The type `SanityImageAsset` does not explicitly define the field `childImageSharp`.
On types with the `@dontInfer` directive, or with the `infer` extension set to `false`, automatically adding fields for children types is deprecated.
In Gatsby v3, only children fields explicitly set with the `childOf` extension will be added.

success building schema - 0.463s
info Creating landing page: /training-materials/
info Creating landing page: /aquarium-of-genova/
info Creating landing page: /about-in-tour-sub-level-1-page-4/
info Creating landing page: /training-material-sub-level-1-page-1/
info Creating landing page: /about-in-tour/
info Creating landing page: /about-in-tour-sub-level-1-page-3/
info Creating landing page: /about-in-tour-sub-level-1-page-2/
info Creating landing page: /consortium-sub-level-page-1/
info Creating landing page: /about-in-tour-sub-level-2-page-1/
info Creating landing page: /about-in-tour-sub-level-2-page-3/
info Creating landing page: /consortium/
info Creating landing page: /about-in-tour-sub-level-1-page-1/
info Creating landing page: /pilots-sub-level-1-page-1-/
info Creating landing page: /about-in-tour-sub-level-2-page-2/
info Creating landing page: /about-in-tour-sub-level-1-page-5/
info Creating landing page: /pilots-page/
success createPages - 0.094s
success createPagesStatefully - 0.048s
success onPreExtractQueries - 0.003s
success update schema - 0.038s
success extract queries from components - 0.460s
success write out requires - 0.005s
success write out redirect data - 0.005s
success Build manifest and related icons - 0.109s
success onPostBootstrap - 0.115s
⠀
info bootstrap finished - 6.283s
⠀
success Building production JavaScript and CSS bundles - 12.942s
success Rewriting compilation hashes - 0.010s
[====                        ]   13.117 s 4/23 17% run queries

 ERROR

f6831b11-df2c-4ea0-aa79-d729e0696d1e


 ERROR

Invalid string length



  RangeError: Invalid string length

  - JSON.stringify

  - query-runner.js:130 queryRunner
    [web]/[gatsby]/dist/query/query-runner.js:130:27

  - task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5

  - task_queues.js:66 runNextTicks
    internal/process/task_queues.js:66:3

  - timers.js:429 processImmediate
    internal/timers.js:429:9



 ERROR

UNHANDLED REJECTION Cannot read property 'sourceMessage' of undefined



  TypeError: Cannot read property 'sourceMessage' of undefined

  - error-map.js:12 Object.text
    [lib]/[gatsby-cli]/lib/structured-errors/error-map.js:12:37

  - construct-error.js:32 constructError
    [lib]/[gatsby-cli]/lib/structured-errors/construct-error.js:32:18

  - index.js:194 Object.error
    [lib]/[gatsby-cli]/lib/reporter/index.js:194:29

  - index.js:185
    [lib]/[gatsby-cli]/lib/reporter/index.js:185:46

  - Array.map

  - index.js:185 Object.error
    [lib]/[gatsby-cli]/lib/reporter/index.js:185:24

  - index.js:144 Object.panic
    [lib]/[gatsby-cli]/lib/reporter/index.js:144:28

  - create-cli.js:31
    [lib]/[gatsby-cli]/lib/create-cli.js:31:74

  - task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5

  - task_queues.js:66 runNextTicks
    internal/process/task_queues.js:66:3

  - timers.js:429 processImmediate
    internal/timers.js:429:9

not finished run queries - 85.021s
Aug 18, 2020, 8:53 AM
Turns out that setting resolveReferences depth too high causes this
_rawContent(resolveReferences: { maxDepth: 50 })
Changed to
_rawContent(resolveReferences: { maxDepth: 20 })
Aug 18, 2020, 9:29 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?