craftcms / gatsby-source-craft

Gatsby source plugin for Craft CMS.
MIT License
54 stars 13 forks source link

Gatsby Cloud builds fail often via webhook and manual rebuilds #49

Closed emson-digital closed 3 years ago

emson-digital commented 3 years ago

Description

Having some very consistent, but inconsistent errors. Most of the time I can run "Clear Cache and Rebuild" and the site will rebuild without error, but not always. Almost always if a rebuild is triggered by webhook it will fail, but very rarely it will succeed.

If I run local builds 'Gatsby Develop' I never get a failure. But those are never triggered by webhook.

image

Error is sometimes:

Triggered by Gatsby Build webhook Build failed for branch staging Failed after 0:10

Raw logs "gatsby-source-craft" threw an error while running the sourceNodes lifecycle:

Cannot read property 'map' of null

488 | // Create the sourcing node events 489 | const nodeEvents = [

490 | ...updatedNodes.map(entry => { | ^ 491 | return { 492 | eventName: 'UPDATE', 493 | remoteTypeName: entry.nodeType,

Error is sometimes:

Triggered by Gatsby Build webhook Build failed for branch staging Failed after 0:19

Raw logs "gatsby-source-craft" threw an error while running the onPreBootstrap lifecycle:

request to https://[redacted].com/api failed, reason: getaddrinfo EAI_AGAIN [redacted].com

For more details see https://gatsby.dev/issue-how-to

Steps to reproduce

  1. Make an edit in the CMS.
  2. Save
  3. Wait for error message in Gatsby Cloud. image or image

Additional info

Google Cloud Storage 1.4.1 Google Cloud Storage integration for Craft CMS

Incognito Field 1.2.0 PlainText drop-in replacement that can be set to disabled, hidden or readonly.

Navigation 1.4.21 A Craft CMS plugin to create navigation menus for your site.

Neo 2.11.9 A Matrix-like field type that uses existing fields

Redactor 2.8.8 Edit rich text content in Craft CMS using Redactor by Imperavi.

SEOmatic 3.4.6 SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.

Webhooks

Additional Info:

image

andris-sevcenko commented 3 years ago

Can you check Craft logs? The first error would happen if Craft did not return an array there for the GraphQL query, however, it's not possible unless some error occurs which just throws the entire query off (https://github.com/craftcms/gatsby-helper/blob/main/src/gql/resolvers/UpdatedNode.php#L29).

The second error is a generic network DNS lookup error that is not something that would be related to Craft.(https://www.codingdefined.com/2015/06/nodejs-error-errno-eaiagain.html)

glitton commented 3 years ago

Hello, Adding more details on this issue. We see that the error occurs when deleting nodes. 2 examples are below.

`16:27:29 PM: ERROR "gatsby-source-craft" threw an error while running the sourceNodes lifecycle:

16:27:29 PM: | ^

16:27:29 PM:

512 | await sourceNodeChanges(config, { nodeEvents });

16:27:29 PM: 513 | }

16:27:29 PM: 514 | await cache.set(CRAFT_CONFIG_VERSION, remoteConfigVersion);

16:27:29 PM: 511 | // And source, if needed

16:27:29 PM: 515 | await cache.set(CRAFT_LAST_CONTENT_UPDATE, remoteContentUpdateTime);

16:27:29 PM:

16:27:29 PM: 16:27:29 PM: Error: Unknown type contentBuilder_faq_BlockType

16:27:29 PM: [www]/[gatsby-graphql-source-toolkit]/src/source-nodes/node-actions/delete-n odes.ts:10:13

16:27:29 PM:

16:27:29 PM:`

`16:35:36 PM: info Sourcing changes for 89 nodes.

16:35:36 PM: ERROR "gatsby-source-craft" threw an error while running the sourceNodes lifecycle:

16:35:36 PM: Unknown type contentBuilder_faq_BlockType

16:35:36 PM: 511 | // And source, if needed

16:35:36 PM: | ^

16:35:36 PM:

512 | await sourceNodeChanges(config, { nodeEvents });

16:35:36 PM: 510 | }

16:35:36 PM: 513 | }

16:35:36 PM: 514 | await cache.set(CRAFT_CONFIG_VERSION, remoteConfigVersion);

16:35:36 PM: 515 | await cache.set(CRAFT_LAST_CONTENT_UPDATE, remoteContentUpdateTime);

16:35:36 PM: Error: Unknown type contentBuilder_faq_BlockType

16:35:36 PM: 16:35:36 PM:

16:35:36 PM: [www]/[gatsby-graphql-source-toolkit]/src/source-nodes/node-actions/delete-n odes.ts:10:13

16:35:36 PM:

16:35:36 PM:

16:35:36 PM:

16:35:36 PM: [www]/[gatsby-graphql-source-toolkit]/src/source-nodes/source-node-changes.t s:34:9

16:35:36 PM:

16:35:36 PM:`

emson-digital commented 3 years ago

More to add. Previews build as expected and never seem to fail. Just when I save the entry through the CMS and trigger a build.

Preview with expected changes. In this case I added text to the description field and moved the "Embed" block below the Callout Block. image

Result in Gatsby Cloud with error message. image

emson-digital commented 3 years ago

image

emson-digital commented 3 years ago

Clearing cache and rebuilding on Gatsby side allows for a clean build, but will still error with the next incremental change from the CMS webhook.

image

andris-sevcenko commented 3 years ago

This is an issue with the Neo plugin. It's not really a bug, it's just that support for Gatsby Helper/source plugin has not been added yet. I've opened an issue there and also provided a fix, so this should be resolved rather quickly.

ttempleton commented 3 years ago

Should be resolved with Neo 2.11.11.1, thanks again @andris-sevcenko for bringing this to our attention.

andris-sevcenko commented 3 years ago

@emson-digital can you update to Neo 2.11.11.1 and give it another shot?

emson-digital commented 3 years ago

@andris-sevcenko that seems to have resolved it. I haven't been able to produce a build error today. Much appreciated to you and @ttempleton !