gatsby: Missing onError handler for invocation 'rebuildSchemaWithSitePage'

Description

Missing onError handler for invocation 'rebuildSchemaWithSitePage', error was 'TypeError: Cannot read property 'contents' of null'. Stacktrace was 'TypeError: Cannot read property 'contents' of null
    at get (/home/simon/tmp/bug-repro/node_modules/gatsby/src/utils/get-value-at.ts:10:20)
    at map (/home/simon/tmp/bug-repro/node_modules/gatsby/src/utils/get-value-at.ts:20:59)
    at Array.map (<anonymous>)
    at getArray (/home/simon/tmp/bug-repro/node_modules/gatsby/src/utils/get-value-at.ts:19:6)
    at get (/home/simon/tmp/bug-repro/node_modules/gatsby/src/utils/get-value-at.ts:12:36)
    at get (/home/simon/tmp/bug-repro/node_modules/gatsby/src/utils/get-value-at.ts:13:50)
    at get (/home/simon/tmp/bug-repro/node_modules/gatsby/src/utils/get-value-at.ts:13:50)
    at get (/home/simon/tmp/bug-repro/node_modules/gatsby/src/utils/get-value-at.ts:13:50)
    at getValueAt (/home/simon/tmp/bug-repro/node_modules/gatsby/src/utils/get-value-at.ts:4:10)
    at getFirstValueAt (/home/simon/tmp/bug-repro/node_modules/gatsby/src/schema/infer/is-file.ts:14:15)
    at find (/home/simon/tmp/bug-repro/node_modules/gatsby/src/schema/infer/is-file.ts:84:13)
    at Array.find (<anonymous>)
    at getFilePath (/home/simon/tmp/bug-repro/node_modules/gatsby/src/schema/infer/is-file.ts:83:41)
    at isFile (/home/simon/tmp/bug-repro/node_modules/gatsby/src/schema/infer/is-file.ts:91:20)
    at getSimpleFieldConfig (/home/simon/tmp/bug-repro/node_modules/gatsby/src/schema/infer/add-inferred-fields.js:315:11)
    at getFieldConfig (/home/simon/tmp/bug-repro/node_modules/gatsby/src/schema/infer/add-inferred-fields.js:174:19)'

Steps to reproduce

Minimal reproduction: https://github.com/SimonSiefke/gatsby-bug

  1. Run gatsby develop
  2. Error occurs

Expected result

No Error

Actual result

Error

Environment


  System:
    OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.3.0 - ~/.nvm/versions/node/v14.3.0/bin/node
    Yarn: 1.22.4 - ~/.nvm/versions/node/v14.3.0/bin/yarn
    npm: 6.14.5 - ~/.nvm/versions/node/v14.3.0/bin/npm
  Browsers:
    Chrome: 84.0.4147.125
    Firefox: 79.0
  npmPackages:
    gatsby: ^2.24.47 => 2.24.47 
  npmGlobalPackages:
    gatsby-cli: 2.12.87

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 17
  • Comments: 55 (5 by maintainers)

Most upvoted comments

This is also happening in Gatsby V3

Im also having this error in Gatsby V3 , tried gatsby clean and deleting node_modules an reinstalling but the error persist

This is still impacting me too, but not sure how to catch this to get more verbosity:

 ERROR

Missing onError handler for invocation 'building-schema', error was 'Error: Cannot create as TypeComposer the following value:
  JSON.'. Stacktrace was 'Error: Cannot create as TypeComposer the following value:
  JSON.
    at SchemaComposer.createTempTC (/Users/tristan.watson/src/make/node_modules/gatsby/node_modules/graphql-compose/lib/SchemaComposer.js:463:11)
    at SchemaComposer.createTC (/Users/tristan.watson/src/make/node_modules/gatsby/node_modules/graphql-compose/lib/SchemaComposer.js:426:84)
    at SchemaComposer.add (/Users/tristan.watson/src/make/node_modules/gatsby/node_modules/graphql-compose/lib/SchemaComposer.js:715:21)
    at createSchemaComposer (/Users/tristan.watson/src/make/node_modules/gatsby/src/schema/schema-composer.js:17:18)
    at build (/Users/tristan.watson/src/make/node_modules/gatsby/src/schema/index.js:104:26)
    at buildSchema (/Users/tristan.watson/src/make/node_modules/gatsby/src/services/build-schema.ts:19:3)'

⠙ building schema
❯ gatsby --version
Gatsby CLI version: 3.4.0
Gatsby version: 3.6.1
  Note: this is the Gatsby version for the site at: /Users/tristan.watson/src/make

https://github.com/gatsbyjs/gatsby-starter-landing-page

 ERROR 
 
 Missing onError handler for invocation 'building-schema', error was 'Error: Type with name "contentfulLandingPageContentPrimaryTextTextNode" does not exists'. Stacktrace was 'Error: Type with name
 "contentfulLandingPageContentPrimaryTextTextNode" does not exists
     at SchemaComposer.get (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\TypeStorage.js:44:13)
     at ThunkComposer._thunk (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\TypeMapper.js:585:34)
     at ThunkComposer.get ofType [as ofType] (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\ThunkComposer.js:20:34)
     at getTypeNode (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\utils\definitionNode.js:265:28)
     at C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\utils\definitionNode.js:317:18
     at Array.map (<anonymous>)
     at getFieldDefinitionNodes (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\utils\definitionNode.js:315:21)
     at getObjectTypeDefinitionNode (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\utils\definitionNode.js:40:13)
     at ObjectTypeComposer.getType (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\ObjectTypeComposer.js:700:76)
     at ThunkComposer.getType (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\ThunkComposer.js:46:24)
     at ListComposer.getType (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\ListComposer.js:22:49)
     at ObjectTypeComposer.getFieldConfig (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\graphql-compose\lib\ObjectTypeComposer.js:348:18)
     at forEach (C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\gatsby\src\schema\extensions\index.js:220:48)
     at Array.forEach (<anonymous>)
     at C:\Users\User\Documents\Gatsby\my-landing-page-site\node_modules\gatsby\src\schema\extensions\index.js:215:8
     at Array.forEach (<anonymous>)'
 
 ⠴ building schema

Getting stuck here, both on my bare metal and Gatsby coud build. Already tried all the suggestions from the above. Any ideas for debugging this?

Got the same problem on gatsby@5.4.0 while just simply starting a starter project. Tried all suggestions above all and nothing seems to work

Does gatsby clean work for you? I think it is working for me.

managed to get unstuck by moving from npm to yarn after running “rm -rf node_modules && rm -rf package-lock.json”

I ran into this very similar error again, updating a different project from 4 to 5:

PS C:\Users\alexa\gs3> npm run dev

> gs3@1.3.5 dev
> gatsby develop

success compile gatsby files - 1.283s
success load gatsby config - 0.022s
warn Plugin gatsby-plugin-react-leaflet is not compatible with your gatsby version 5.0.1 - It requires gatsby@^2.0.0 || ^3.0.0 || ^4.0.0
warn Plugin gatsby-plugin-react-leaflet is not compatible with your gatsby version 5.0.1 - It requires gatsby@^2.0.0 || ^3.0.0 || ^4.0.0
success load plugins - 0.489s
success onPreInit - 0.004s                                                                                                                                                                                                                
success initialize cache - 0.090s
success copy gatsby files - 0.236s
success Compiling Gatsby Functions - 0.278s
success onPreBootstrap - 0.313s
success createSchemaCustomization - 0.001s
success Checking for changed pages - 0.001s                                                                                                                                                                                               
success source and transform nodes - 0.057s                                                                                                                                                                                               

 ERROR 

Missing onError handler for invocation 'building-schema', error was 'Error: Cannot create as TypeComposer the following value:
  GraphQLScalarType({ name: "Date", description: "A date string, such as 2007-12-03, compliant with the ISO 8601 standard for representation of dates and times using the Gregorian calendar.", specifiedByURL: undefined, serialize:     
[function String], parseValue: [function String], parseLiteral: [function parseLiteral], extensions: {  }, astNode: undefined, extensionASTNodes: [] }).'. Stacktrace was 'Error: Cannot create as TypeComposer the following value:      
  GraphQLScalarType({ name: "Date", description: "A date string, such as 2007-12-03, compliant with the ISO 8601 standard for representation of dates and times using the Gregorian calendar.", specifiedByURL: undefined, serialize:     
[function String], parseValue: [function String], parseLiteral: [function parseLiteral], extensions: {  }, astNode: undefined, extensionASTNodes: [] }).
    at SchemaComposer.createTempTC (C:\Users\alexa\gs3\node_modules\graphql-compose\src\SchemaComposer.ts:624:11)
    at SchemaComposer.createTC (C:\Users\alexa\gs3\node_modules\graphql-compose\src\SchemaComposer.ts:580:66)
    at SchemaComposer.add (C:\Users\alexa\gs3\node_modules\graphql-compose\src\SchemaComposer.ts:876:21)
    at createSchemaComposer (C:\Users\alexa\gs3\node_modules\gatsby\src\schema\schema-composer.ts:21:18)
    at build (C:\Users\alexa\gs3\node_modules\gatsby\src\schema\index.js:110:26)
    at buildSchema (C:\Users\alexa\gs3\node_modules\gatsby\src\services\build-schema.ts:19:3)'

There seems to be a possible problem with gatsby-plugin-react-leaflet (https://github.com/dweirich/gatsby-plugin-react-leaflet/issues/31) but the error message does not seem to relate to that.

Edit: Above error was due to multiple competing versions of graphql used by dependencies. See https://www.gatsbyjs.com/docs/reference/release-notes/migrating-from-v4-to-v5/#multiple-versions-of-graphql, also for solutions.

It happens again on Gatsby version 4.10.0

I’m experiencing the same issue on Gatsby Version 3.10.0

Also happening on “gatsby”: “^4.14.0”, This problem has been around for so long, is there a good solution ?

Missing onError handler for invocation 'building-schema', error was 'Error: Cannot create as TypeComposer the following value:

Still happening on:

Gatsby CLI version: 3.10.0 Gatsby version: 3.9.1

after adding the gatsby-source-rest-api plugin.

Should this not be re-opened?

I was able to solve this in V3 but updating graphql to version “^15.4.0”

Facing the same issue on gatsby@^4.9.3 and gatsby-cli@3.11.0

Screen Shot 2022-03-21 at 19 21 19

We just published gatsby@2.24.49 which fixes the root problem. I locally checked the provided reproduction and it no longer result in this error after upgrading gatsby.

I could solve this issue by removing graphql from my project.

image

It’s not needed, gatsby has its own via import { graphql } from 'gatsby';

Thank you @barbalex for your comments - that was a lifesaver when upgrading 4->5.

I’m leaving my notes in case someone else like me finds this.

In my case, it was also competing graphql, but it was the gatsby images/sharp/transfomer plugins asking for 16 and gatsby 5 asking for 15. Running npm ls graphql gave me this (truncated):

├─┬ gatsby-plugin-image@3.0.0
│ └─┬ gatsby-plugin-utils@4.0.0
│   └── graphql@16.6.0
├─┬ gatsby-plugin-manifest@5.0.0
│ └─┬ gatsby-plugin-utils@4.0.0
│   └── graphql@16.6.0
├─┬ gatsby-plugin-sharp@5.0.0
│ └─┬ gatsby-plugin-utils@4.0.0
│   └── graphql@16.6.0
├─┬ gatsby-transformer-sharp@5.0.0
│ └─┬ gatsby-plugin-utils@4.0.0
│   └── graphql@16.6.0
└─┬ gatsby@5.0.1
  ├─┬ @graphql-codegen/add@3.2.1
  │ └── graphql@15.8.0

I fixed this by deleting node_modules and package-lock.json, and then running:

npm install --legacy-peer-deps
gatsby clean && gatsby develop

It all seems to be at graphql@16.6.0 now.

Original error was:

Missing onError handler for invocation 'building-schema', error was 'Error: Cannot create as TypeComposer the
following value:
  GraphQLScalarType({ name: "Date", description: "A date string, such as 2007-12-03, compliant with the ISO
8601 standard for representation of dates and times using the Gregorian calendar.", specifiedByURL: undefined,
serialize: [function String], parseValue: [function String], parseLiteral: [function parseLiteral], extensions:
 {  }, astNode: undefined, extensionASTNodes: [] }).'. Stacktrace was 'Error: Cannot create as TypeComposer the
 following value:
  GraphQLScalarType({ name: "Date", description: "A date string, such as 2007-12-03, compliant with the ISO
8601 standard for representation of dates and times using the Gregorian calendar.", specifiedByURL: undefined,
serialize: [function String], parseValue: [function String], parseLiteral: [function parseLiteral], extensions:
 {  }, astNode: undefined, extensionASTNodes: [] }).

Running gatsby clean solved it for me

its happening to me too, when i edit the markdown content, its error always showing and server stuck. after restart the server then no error, and i edit the markdown content again, error showing again 😐

Also happening on gatsby@2.30.1gatsby-cli@2.15.0 and i solved this issue by delete the sanity plugin

Its happening again on gatsby@2.24.86

Gatsby has been clearly completely killed by Netlify. It’s time for everyone to migrate to Astro, if anyone is still here… I’ve migrated a huge project to Astro, it’s missing some of the nice features Gatsby had (components shadowing mostly) but it’s doable and the end result is so much more performant…

Missing onError handler for invocation ‘building-schema’, error was ‘Error: Cannot create as TypeComposer the following value: GraphQLScalarType({ name: “Date”, description: “A date string, such as 2007-12-03, compliant with the ISO 8601 standard for representation of dates and times using the Gregorian calendar.”, specifiedByURL: undefined, serialize: [function String], parseValue: [function String], parseLiteral: [function parseLiteral], extensions: { }, astNode: undefined, extensionASTNodes: [] }).’. Stacktrace was 'Error: Cannot create as TypeComposer the following value: GraphQLScalarType({ name: “Date”, description: “A date string, such as 2007-12-03, compliant with the ISO 8601 standard for representation of dates and times using the Gregorian calendar.”, specifiedByURL: undefined, serialize: [function String], parseValue: [function String], parseLiteral: [function parseLiteral], extensions: { }, astNode: undefined, extensionASTNodes: [] }).

Experiencing the same error in gatsby while updating from version 3 to version 5.

managed to get unstuck by moving from npm to yarn after running “rm -rf node_modules && rm -rf package-lock.json”

moving from npm to yarn worked out for me too

Also happening on @gatsby@^2.24.91