gatsby: GraphQL Error 'Invariant violation: inconsistent node counters detected' with gatsby-source-contentful downloadLocal option
Preliminary Checks
- This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
- This issue is not a question, feature request, RFC, or anything other than a bug report directly related to Gatsby. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions
Description
Now that the issues (https://github.com/gatsbyjs/gatsby/issues/33871) with gatsby-source-contentful’s downloadLocal option have been resolved, we’ve upgraded to Gatsby 4. However, we’re running into a different but completely debilitating issue which is breaking the vast majority of our Gatsby Cloud Preview builds, incremental production builds and which surfaces while navigating in Gatsby develop as well.
On a clean build, everything seems to work fine in all environments. On develop, stopping and restarting the develop process one or two times and then clicking around triggers the error. On Gatsby Cloud, “clear cache and (re)build succeeds”, but incremental builds fail almost 100% of the time. Gatsby Preview is entirely useless. We’re stuck clearing cache and rebuilding constantly. For us this takes 20-40 mins.
ERROR #85901 GRAPHQL
There was an error in your GraphQL query:
Invariant violation: inconsistent node counters detected
45 | }
46 | }
47 | childContentfulBlogPostContentTextNode {
48 | childMarkdownRemark {
49 | timeToRead
50 | }
51 | }
52 | }
53 |
54 | fragment BlogCta on Query {
> 55 | blogCtaCardImage: contentfulAsset(
| ^
56 | contentful_id: {eq: "3RwyPsi3e24HPSwglySxnI"}
57 | node_locale: {eq: $locale}
58 | ) {
59 | title
60 | localFile {
61 | childImageSharp {
62 | gatsbyImageData(width: 280)
63 | }
64 | }
65 | }
File path: /Users/andrew/Repositories/www/src/templates/Blog.js
Url path: /blog/
Plugin: none
Error: Invariant violation: inconsistent node counters detected
- indexing.ts:986 intersectNodesByCounter
[www]/[gatsby]/src/datastore/in-memory/indexing.ts:986:15
- run-fast-filters.ts:106 applyFastFilters
[www]/[gatsby]/src/datastore/in-memory/run-fast-filters.ts:106:30
- run-fast-filters.ts:347 convertAndApplyFastFilters
[www]/[gatsby]/src/datastore/in-memory/run-fast-filters.ts:347:18
- run-fast-filters.ts:282 runFastFiltersAndSort
[www]/[gatsby]/src/datastore/in-memory/run-fast-filters.ts:282:18
- lmdb-datastore.ts:176 Object.runQuery
[www]/[gatsby]/src/datastore/lmdb/lmdb-datastore.ts:176:26
- node-model.js:347 LocalNodeModel._query
[www]/[gatsby]/src/schema/node-model.js:347:58
- runMicrotasks
- task_queues.js:95 processTicksAndRejections
internal/process/task_queues.js:95:5
- node-model.js:415 LocalNodeModel.findOne
[www]/[gatsby]/src/schema/node-model.js:415:34
- async Promise.all
- graphql-runner.ts:220 GraphQLRunner.query
[www]/[gatsby]/src/query/graphql-runner.ts:220:14
- query-runner.ts:135 queryRunner
[www]/[gatsby]/src/query/query-runner.ts:135:14
I’ve had to rollback to Gatsby 3 which is soul destroying after this much time.
I’m happy to do literally anything I can to help get this resolved. I can point you to any of our cloud builds or share source privately. If you have advice on how to create a minimal reproduction with Contentful, I can try to do that as well. Are there some publicly accessible Contentful instances/guest credentials that can be used?
For my part, I’ve stripped everything out of our config and site I possibly can and the error persists.
Reproduction Link
See comment below: https://github.com/gatsbyjs/gatsby/issues/34616#issuecomment-1029461729
Steps to Reproduce
- Setup
gatsby-source-contentfulwith thedownloadLocaloption enabled. - Reference a
ContentfulAssetin graphql (all of ours use thelocalFilenode as above in error) - Run
gatsby develop, click around a bit. - Stop and restart
gatsby develop(once or twice seems to guarantee it). - Refresh or re-navigate to a page referencing the ContentfulAsset.
Alternatively, a Gatsby Preview update triggered by a Preview Webhook fails 100% of the time (except when it randomly decides to run a full build after enough failures).
Expected Result
It shouldn’t error and all images should be presented.
Actual Result
GraphQL Error: Invariant violation: inconsistent node counters detected error is displayed both in console and in gatsby develop pop over. For Preview and incremental builds the build fails with this same error.
Environment
System:
OS: macOS 12.3
CPU: (10) x64 Apple M1 Max
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node
Yarn: 1.22.17 - /opt/homebrew/bin/yarn
npm: 6.14.14 - ~/.nvm/versions/node/v14.17.5/bin/npm
Browsers:
Chrome: 97.0.4692.99
Firefox: 96.0.3
Safari: 15.4
npmPackages:
gatsby: ^4.5.0 => 4.6.0
gatsby-plugin-catch-links: ^4.5.0 => 4.6.0
gatsby-plugin-env-variables: ^2.2.0 => 2.2.0
gatsby-plugin-graphql-codegen: ^3.1.0 => 3.1.0
gatsby-plugin-image: ^2.5.1 => 2.6.0
gatsby-plugin-loadable-components-ssr: 4.1.1 => 4.1.1
gatsby-plugin-lodash: ^5.5.0 => 5.6.0
gatsby-plugin-mailchimp: ^5.2.2 => 5.2.2
gatsby-plugin-react-helmet: ^5.4.0 => 5.6.0
gatsby-plugin-react-svg: ^3.1.0 => 3.1.0
gatsby-plugin-robots-txt: ^1.6.14 => 1.7.0
gatsby-plugin-sharp: ^4.5.1 => 4.6.0
gatsby-plugin-styled-components: ^5.5.0 => 5.6.0
gatsby-remark-autolink-headers: ^5.5.0 => 5.6.0
gatsby-source-contentful: ^7.3.0 => 7.4.0
gatsby-source-filesystem: ^4.5.1 => 4.6.0
gatsby-transformer-remark: ^5.5.1 => 5.6.0
gatsby-transformer-sharp: ^4.5.0 => 4.6.0
Config Flags
N/A
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (4 by maintainers)
@chunksnbits could you check if removing the
sortsolve the problem? Why I’m asking:We recently updated Gatsby from 4.7.2 to 4.8.0 and got the same error as you. But in our case Gatsby is connected to Drupal (instead of Contentful) via a custom integration.
I suspected that something can be wrong with
contentHubMetadata___datesorting. Because previously this field was marked as deprecated (but now it is not 🤷). So I tried to remove it and the error disappeared.And in the changelog record for Gatsby 4.8.0 I found
which sound like something that can be related.
Also
gatsby buildgatsby developthe page using the query works just fine/___graphql