Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"gatsby-source-craft" threw an error while running the sourceNodes lifecycle #50

Closed
mmorkt opened this issue Oct 6, 2021 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@mmorkt
Copy link

mmorkt commented Oct 6, 2021

Description

I'm getting this error when running two sites with diffrent URL’s. The main site should be headless, the second site got some minor functions where I’m using Crafts CMS' templating engine.

After setting up the second site my GatsbyJS site wont build anymore and I’m getting this error. The only workaround so far is to run “garsby clean”. after making an update or changes on entries.

ERROR #11321  PLUGIN
"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,

File: node_modules/gatsby-source-craft/gatsby-node.js:490:29

  TypeError: Cannot read property 'map' of null
  
  - gatsby-node.js:490 Object.exports.sourceNodes
    [stm-web]/[gatsby-source-craft]/gatsby-node.js:490:29
  
  - task_queues:96 processTicksAndRejections
    node:internal/process/task_queues:96:5
  
  - api-runner-node.js:432 runAPI
    [stm-web]/[gatsby]/src/utils/api-runner-node.js:432:16

Steps to reproduce

  1. Setup Craft with multiple sites, don't share the sections
  2. Run gatsby develop
  3. Add a page
  4. Refresh data

Additional info

  • Craft version: 3.7.15
  • PHP version: 7.3.31
  • Database driver & version: MySQL 5.6.51
  • Plugins & versions:
  • Cloner: 1.2.2
  • Gatsby Helper: 1.0.5
  • Redactor: 2.8.8
  • Smith: 1.1.14
  • Spoon: 3.6.1
  • Sprout Notes: 2.2.3
  • Tags: 1.0.8
@mmorkt mmorkt added the bug Something isn't working label Oct 6, 2021
@andris-sevcenko
Copy link
Contributor

This is most likely due to the Tags plugin by Ether Creative.

I'm not sure what their plans are regarding GraphQL support for the enhanced Tag element the plugin provides, but, at the very least, until they add that support and provide a Gatsby integration, the plugin should let Gatsby know that their element type should be excluded from updates. I've opened a new issue in their repository for this. (ethercreative/tags#20)

@andris-sevcenko
Copy link
Contributor

@mmorkt can you update Tags plugin to 1.0.9 and check if the issue is resolved?

@mmorkt
Copy link
Author

mmorkt commented Oct 8, 2021

We reactivated the seccond site and installed Tags 1.0.9, but it didn't help, we are getting the same error.
As for now, we are just using the main site. Seems like this only happens on our production server. Locally it works with no errors.

We tried:
• Restore the DB
• Delete vendor and composer install
• rebuild configs ... and a lot more

@andris-sevcenko
Copy link
Contributor

@mmorkt Can you check Craft logs for this, please? There should be an error that occurs during the GraphQL request to fetch updated content information.

@andreasottosson
Copy link

@andris-sevcenko This is the error from web.log

2021-10-08 11:57:30 [-][-][-][error][Error] Error: Call to a member function getGqlTypeName() on null in /home/.../tsakansdzy/public_html/vendor/craftcms/gatsby-helper/src/gql/resolvers/UpdatedNode.php:35
Stack trace:
#0 /home/.../tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(624): craft\gatsbyhelper\gql\resolvers\UpdatedNode::resolve(NULL, Array, Array, Object(GraphQL\Type\Definition\ResolveInfo))
#1 /home/.../tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(550): GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError(Object(GraphQL\Type\Definition\FieldDefinition), Object(GraphQL\Language\AST\FieldNode), 'craft\\gatsbyhel...', NULL, Object(GraphQL\Type\Definition\ResolveInfo))
#2 /home/.../tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1196): GraphQL\Executor\ReferenceExecutor->resolveField(Object(GraphQL\Type\Definition\ObjectType), NULL, Object(ArrayObject), Array)
#3 /home/.../tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(264): GraphQL\Executor\ReferenceExecutor->executeFields(Object(GraphQL\Type\Definition\ObjectType), NULL, Array, Object(ArrayObject))
#4 /home/.../tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(215): GraphQL\Executor\ReferenceExecutor->executeOperation(Object(GraphQL\Language\AST\OperationDefinitionNode), NULL)
#5 /home/.../tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/Executor.php(156): GraphQL\Executor\ReferenceExecutor->doExecute()
#6 /home/.../tsakansdzy/public_html/vendor/webonyx/graphql-php/src/GraphQL.php(162): GraphQL\Executor\Executor::promiseToExecute(Object(GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter), Object(GraphQL\Type\Schema), Object(GraphQL\Language\AST\DocumentNode), NULL, Array, Array, 'nodeChanges', NULL)
#7 /home/.../tsakansdzy/public_html/vendor/webonyx/graphql-php/src/GraphQL.php(94): GraphQL\GraphQL::promiseToExecute(Object(GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter), Object(GraphQL\Type\Schema), 'query nodeChang...', NULL, Array, Array, 'nodeChanges', NULL, Array)
#8 /home/.../tsakansdzy/public_html/vendor/craftcms/cms/src/services/Gql.php(544): GraphQL\GraphQL::executeQuery(Object(GraphQL\Type\Schema), 'query nodeChang...', NULL, Array, Array, 'nodeChanges', NULL, Array)
#9 /home/.../tsakansdzy/public_html/vendor/craftcms/cms/src/controllers/GraphqlController.php(172): craft\services\Gql->executeQuery(Object(craft\models\GqlSchema), 'query nodeChang...', Array, 'nodeChanges', true)
#10 [internal function]: craft\controllers\GraphqlController->actionApi()
#11 /home/.../tsakansdzy/public_html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /home/.../tsakansdzy/public_html/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#13 /home/.../tsakansdzy/public_html/vendor/craftcms/cms/src/web/Controller.php(189): yii\base\Controller->runAction('api', Array)
#14 /home/.../tsakansdzy/public_html/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('api', Array)
#15 /home/.../tsakansdzy/public_html/vendor/craftcms/cms/src/web/Application.php(277): yii\base\Module->runAction('graphql/api', Array)
#16 /home/.../tsakansdzy/public_html/vendor/yiisoft/yii2/web/Application.php(104): craft\web\Application->runAction('graphql/api', Array)
#17 /home/.../tsakansdzy/public_html/vendor/craftcms/cms/src/web/Application.php(262): yii\web\Application->handleRequest(Object(craft\web\Request))
#18 /home/.../tsakansdzy/public_html/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#19 /home/.../tsakansdzy/public_html/web/index.php(26): yii\base\Application->run()
#20 {main}

@andris-sevcenko
Copy link
Contributor

@andreasottosson @mmorkt ah okay. I see how I can be more defensive against this. I'm curios, though, how this might have happened.

Seems like the data is a bit messed up there - there is an updated element but it has incomplete information. Is it possible for you to send over the elements table from the database for the affected site? I should be able to make a more educated judgment on how to approach this.

If this is possible, can you, please, send it over to [email protected] and mention this GH issue? Thank you!

@andreasottosson
Copy link

@andris-sevcenko of course! I have sent it via e-mail now. Sorry, it's 18.000+ lines 😬 This is probably some weird edge case, if we clone the site and run it locally in containers (Craft official docker image) this problem goes away. And also as mentioned if we disable "multisite". One thing to know is that we have had "Formie" installed on this site and that caused a lot of other GQL related errors. Don't know if they are related though. Have a nice weekend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants