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

Regression?: "gatsby-source-craft" threw an error while running the sourceNodes lifecycle bug #57

Closed
andreasottosson opened this issue Nov 24, 2021 · 28 comments
Labels
bug Something isn't working

Comments

@andreasottosson
Copy link

andreasottosson commented Nov 24, 2021

Description

This issue was fixed (#50) but has now reappeared. Somehow as soon as Gatsby tries to use the cache to do a build this error occurs. We do not have multisite enabled this time. Site is built on Netlify with "Essential Gatsby" plugin installed.

The only reason we use this plugin instead of "gatsby-source-graphql" is for incremental builds but it seems to just break instead. I also see this line in the official documentation about missing data with incremental builds,

This means that sometimes incremental sourcing can make your site have some obsolete content. For this reason, it is recommended to do a full page build (by cleaning the Gatsby caches beforehand) before deploying the built site.

could it be related? We can't possibly ask the customer to clear the cache when they change something on the site :)

@andris-sevcenko any ideas? We would be happy to give you access to the server again if you need to look around.

8:54:58 AM: info Checking Craft config version.
8:54:59 AM: info Craft config version has not changed since last sourcing. Checking for content changes since "2021-11-23 19:49:33".
8:55:00 AM: error "gatsby-source-craft" threw an error while running the sourceNodes lifecycle:
8:55:00 AM: Cannot read properties of null (reading 'map')
8:55:00 AM:   488 |         // Create the sourcing node events
8:55:00 AM:   489 |         const nodeEvents = [
8:55:00 AM: > 490 |             ...updatedNodes.map(entry => {
8:55:00 AM:       |                             ^
8:55:00 AM:   491 |                 return {
8:55:00 AM:   492 |                     eventName: 'UPDATE',
8:55:00 AM:   493 |                     remoteTypeName: entry.nodeType,
8:55:00 AM: 
8:55:00 AM: 
8:55:00 AM:   TypeError: Cannot read properties of null (reading 'map')
8:55:00 AM:   
8:55:00 AM:   - gatsby-node.js:490 Object.exports.sourceNodes
8:55:00 AM:     [repo]/[gatsby-source-craft]/gatsby-node.js:490:29
8:55:00 AM:   
8:55:00 AM:   - task_queues:96 processTicksAndRejections
8:55:00 AM:     node:internal/process/task_queues:96:5
8:55:00 AM:   
8:55:00 AM:   - api-runner-node.js:430 runAPI
8:55:00 AM:     [repo]/[gatsby]/src/utils/api-runner-node.js:430:16
8:55:00 AM:   
8:55:00 AM: 
8:55:00 AM: not finished source and transform nodes - 2.259s
8:55:00 AM: ​
8:55:00 AM: ────────────────────────────────────────────────────────────────
8:55:00 AM:   "build.command" failed                                        
8:55:00 AM: ────────────────────────────────────────────────────────────────

Steps to reproduce

  1. Make a change to random entry
  2. Build site on Netlify
  3. Sometimes it works, sometimes it don't and we get this issue

Additional info

  • Craft version: 3.7.21
  • PHP version: 7.3.31
  • Database driver & version: MySQL 5.6.51
  • Plugins & versions:
    Cloner 1.2.2
    Formie 1.4.26
    Gatsby Helper 1.0.7
    Redactor 2.8.8
    Smith 1.1.14
    Spoon 3.6.1
    Sprout Notes 2.2.3
    Tags 1.0.9
@andreasottosson andreasottosson added the bug Something isn't working label Nov 24, 2021
@andris-sevcenko
Copy link
Contributor

It's not guaranteed to be the same error. It's just the same symptom, though.

There should be something in your Craft logs, since Craft fails to return content. Can you take a look?

@andreasottosson
Copy link
Author

That's true, it's so weird that this error keeps popping up at random times. Today we can't seem to reproduce it and unfortunately the logs from yesterday has been overwritten already it seems like. This error would show up in web.log right?

@andris-sevcenko
Copy link
Contributor

@andreasottosson It would, yeah, if the query failed to return a response due to Craft error. Maybe in server error logs if web server tapped out? But the issue you referenced before definitely showed up in web.log :)

Disabling devMode helps reduce the noise in log files, too.

@andreasottosson
Copy link
Author

andreasottosson commented Nov 25, 2021

@andris-sevcenko Good point, we disabled dev mode now and if the error comes back I will update you. We can close this if you want, I can just create a new issue when I have the logs from Craft so we have some more info.

@andris-sevcenko
Copy link
Contributor

Will do!

@andreasottosson
Copy link
Author

@andris-sevcenko Got the error again today, does this tell you anything?

2021-11-29 14:46:06 [-][-][-][error][PDOException] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'dateUpdated' in where clause is ambiguous in /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/db/Command.php:1302
Stack trace:
#0 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/db/Command.php(1302): PDOStatement->execute()
#1 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT `e`.`id`...')
#2 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#5 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/gatsby-helper/src/services/Deltas.php(118): craft\db\Query->all()
#6 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/gatsby-helper/src/gql/resolvers/UpdatedNode.php(40): craft\gatsbyhelper\services\Deltas->getUpdatedNodesSinceTimeStamp('2021-11-29 13:4...', Array)
#7 /home/somedomain.com/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))
#8 /home/somedomain.com/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))
#9 /home/somedomain.com/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)
#10 /home/somedomain.com/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))
#11 /home/somedomain.com/tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(215): GraphQL\Executor\ReferenceExecutor->executeOperation(Object(GraphQL\Language\AST\OperationDefinitionNode), NULL)
#12 /home/somedomain.com/tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/Executor.php(156): GraphQL\Executor\ReferenceExecutor->doExecute()
#13 /home/somedomain.com/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)
#14 /home/somedomain.com/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)
#15 /home/somedomain.com/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)
#16 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/controllers/GraphqlController.php(172): craft\services\Gql->executeQuery(Object(craft\models\GqlSchema), 'query nodeChang...', Array, 'nodeChanges', false)
#17 [internal function]: craft\controllers\GraphqlController->actionApi()
#18 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#19 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#20 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('api', Array)
#21 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/web/Application.php(287): yii\base\Module->runAction('graphql/api', Array)
#22 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/web/Application.php(104): craft\web\Application->runAction('graphql/api', Array)
#23 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/web/Application.php(272): yii\web\Application->handleRequest(Object(craft\web\Request))
#24 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#25 /home/somedomain.com/tsakansdzy/public_html/web/index.php(26): yii\base\Application->run()
#26 {main}

@andris-sevcenko
Copy link
Contributor

It does, indeed! Should be an easy fix - at the latest tomorrow!

@andris-sevcenko
Copy link
Contributor

Just pushed a patch in craftcms/gatsby-helper@0432377. Will cut a release momentarily, when I fix another issue.

@andris-sevcenko
Copy link
Contributor

Just released Gatsby Helper plugin 1.0.9 for Craft that fixes this.

@andreasottosson
Copy link
Author

andreasottosson commented Nov 30, 2021

@andris-sevcenko Not so fast Mr.. ;) The QA-department (which is us) has found more errors.

2021-11-30 12:56:04 [-][-][-][error][PDOException] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous in /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/db/Command.php:1302
Stack trace:
#0 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/db/Command.php(1302): PDOStatement->execute()
#1 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT `e`.`id`...')
#2 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#5 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/gatsby-helper/src/services/Deltas.php(118): craft\db\Query->all()
#6 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/gatsby-helper/src/gql/resolvers/UpdatedNode.php(40): craft\gatsbyhelper\services\Deltas->getUpdatedNodesSinceTimeStamp('2021-11-30 10:3...', Array)
#7 /home/somedomain.com/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))
#8 /home/somedomain.com/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))
#9 /home/somedomain.com/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)
#10 /home/somedomain.com/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))
#11 /home/somedomain.com/tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(215): GraphQL\Executor\ReferenceExecutor->executeOperation(Object(GraphQL\Language\AST\OperationDefinitionNode), NULL)
#12 /home/somedomain.com/tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/Executor.php(156): GraphQL\Executor\ReferenceExecutor->doExecute()
#13 /home/somedomain.com/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)
#14 /home/somedomain.com/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)
#15 /home/somedomain.com/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)
#16 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/controllers/GraphqlController.php(172): craft\services\Gql->executeQuery(Object(craft\models\GqlSchema), 'query nodeChang...', Array, 'nodeChanges', false)
#17 [internal function]: craft\controllers\GraphqlController->actionApi()
#18 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#19 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#20 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('api', Array)
#21 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/web/Application.php(287): yii\base\Module->runAction('graphql/api', Array)
#22 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/web/Application.php(104): craft\web\Application->runAction('graphql/api', Array)
#23 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/web/Application.php(272): yii\web\Application->handleRequest(Object(craft\web\Request))
#24 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#25 /home/somedomain.com/tsakansdzy/public_html/web/index.php(26): yii\base\Application->run()
#26 {main}

@andris-sevcenko
Copy link
Contributor

andris-sevcenko commented Nov 30, 2021

has found more errors.

That's strange. That specific SQL error never triggered for me.

As for the second stack trace doesn't seem to be related to this issue at all. Try running composer dump-autoload to fix it.

I just cut the 1.0.9.1 release for the Helper plugin that fixes this.

@andris-sevcenko
Copy link
Contributor

andris-sevcenko commented Nov 30, 2021

It should perhaps be reported on Craft repo but hey, this saves us one more issue.

It's actually in this repo, but, please, create a new issue. Issues are free and creating an issue per separate bugs reduces the number of times we have to use the sentence "Yeah, it's one of the seven bugs reported in that issue" :)

@andreasottosson
Copy link
Author

Thanks for quick reply @andris-sevcenko ! I will remove that second trace form here and will also create another issue for the "deprecation" thing. Hopefully you will find a fix for that SQL error to. Let us know if you need access to our environment again, this is really important for us to get fixed.

@andris-sevcenko
Copy link
Contributor

Hopefully you will find a fix for that SQL error to

It should be fixed by updating the Gatsby Helper plugin to 1.0.9.1

@andreasottosson
Copy link
Author

You work fast, that's the quickest fix I've seen 😊 Thanks, @andris-sevcenko ! We will try again, if it breaks we will let you know.

@andris-sevcenko
Copy link
Contributor

We will try again, if it breaks we will let you know.

Ohhh I know 😆

@andreasottosson
Copy link
Author

@andris-sevcenko LOL, sorry man, we are in a little bit of a hurry with this. To be fair we do pay for Craft Pro on several sites so I don't feel too bad 🤣

@andris-sevcenko
Copy link
Contributor

No problem at all.

@andreasottosson
Copy link
Author

andreasottosson commented Dec 7, 2021

@andris-sevcenko We got this error again today, I tried searching for the error and Google return exactly 2 results. One was spam, one was verbb/super-table#327 that didn't tell me more than that this was fixed in their code and it wasn't the exact same error of course. So I will just leave the stack trace here and you can do what you want with it :)

2021-12-07 09:41:24 [-][-][-][error][craft\errors\GqlException] craft\errors\GqlException: Tried to load an unregistered type "User". This can indicate both a typo in the query or an issue with the schema used. in /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/gql/TypeLoader.php:39
Stack trace:
#0 /home/somedomain.com/tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Type/Schema.php(346): craft\gql\TypeLoader::loadType('User')
#1 /home/somedomain.com/tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Type/Schema.php(322): GraphQL\Type\Schema->loadType('User')
#2 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/gatsby-helper/src/gql/resolvers/UpdatedNode.php(47): GraphQL\Type\Schema->getType('User')
#3 /home/somedomain.com/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))
#4 /home/somedomain.com/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))
#5 /home/somedomain.com/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)
#6 /home/somedomain.com/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))
#7 /home/somedomain.com/tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(215): GraphQL\Executor\ReferenceExecutor->executeOperation(Object(GraphQL\Language\AST\OperationDefinitionNode), NULL)
#8 /home/somedomain.com/tsakansdzy/public_html/vendor/webonyx/graphql-php/src/Executor/Executor.php(156): GraphQL\Executor\ReferenceExecutor->doExecute()
#9 /home/somedomain.com/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)
#10 /home/somedomain.com/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)
#11 /home/somedomain.com/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)
#12 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/controllers/GraphqlController.php(172): craft\services\Gql->executeQuery(Object(craft\models\GqlSchema), 'query nodeChang...', Array, 'nodeChanges', false)
#13 [internal function]: craft\controllers\GraphqlController->actionApi()
#14 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#15 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#16 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('api', Array)
#17 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/web/Application.php(287): yii\base\Module->runAction('graphql/api', Array)
#18 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/web/Application.php(104): craft\web\Application->runAction('graphql/api', Array)
#19 /home/somedomain.com/tsakansdzy/public_html/vendor/craftcms/cms/src/web/Application.php(272): yii\web\Application->handleRequest(Object(craft\web\Request))
#20 /home/somedomain.com/tsakansdzy/public_html/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#21 /home/somedomain.com/tsakansdzy/public_html/web/index.php(26): yii\base\Application->run()
#22 {main}

FWIW, I can't reproduce it right now but it happend. Does not look good for clients editing the site...¨'

UPDATE:
It failed again, but no new logs in web.log, from Gatsby logs:

10:12:14 AM: info Sourcing changes for 48 nodes.
10:12:15 AM: error "gatsby-source-craft" threw an error while running the sourceNodes lifecycle:
10:12:15 AM: Unknown type User
10:12:15 AM:   552 |         }
10:12:15 AM:   553 |         // And source, if needed
10:12:15 AM: > 554 |         await sourceNodeChanges(config, { nodeEvents });
10:12:15 AM:       |         ^
10:12:15 AM:   555 |     }
10:12:15 AM:   556 |     await cache.set(`CRAFT_CONFIG_VERSION`, remoteConfigVersion);
10:12:15 AM:   557 |     await cache.set(`CRAFT_LAST_CONTENT_UPDATE`, lastUpdateTime);
10:12:15 AM: 

FYI, site is now running Craft 3.7.24, all Node plugins are up to date, and also Gatsby helper.

@andris-sevcenko
Copy link
Contributor

In this specific case, it looks like Craft pinged Gatsby build about an updated element (User), however, Gatsby had no permission to query for it.

When building sites with Gatsby, it's probably more prudent to follow a "allow Gatsby to query for everything and narrow it down when building the site."

@andreasottosson
Copy link
Author

Makes sense, "View all users" was unchecked in the Schema. I guess we just have to enable everything and hope it will work, seems like a bit too much permissions but as long as it works we are happy. Thanks!

@andris-sevcenko
Copy link
Contributor

seems like a bit too much permissions but as long as it works we are happy.

Yeah, I agree with that, but there's no clean solution.

The biggest reason for this is because the sourcing plugin does not know what queries are run when building the site and the same goes for the helper plugin. So the helper plugin can't know it shouldn't listen to some certain element updates or not.

The most balanced solution that requires the least effort from the plugin developer is the current one. Or, that's what I think at least. I'm open to suggestions! :)

@andreasottosson
Copy link
Author

Absolutely, I guess for Gatsby it's not a big deal since the API key is never exposed when the site is built.

But unfortunately we are still facing issues. Today we get this error, everything under "Users" is enabled in the Schema now in Craft. The only thing not enabled is, "Allow listing element drafts", "Allow listing element revisions" & "Freeform" categories. Also no mutations. Nothing in web.log. This is from Gatsby build on Netlify,

1:46:53 PM: info Querying for Craft state.
1:46:54 PM: Switch to canonical?
1:46:54 PM: info Craft v3.7.24, running Helper plugin v1.1.0
1:46:54 PM: info Clearing previous fragments.
1:46:54 PM: info Writing default fragments.
1:46:55 PM: info Found 1 additional fragments
1:46:55 PM: info Adding og-image.graphql to additional fragments
1:46:55 PM: success onPreBootstrap - 2.886s
1:46:57 PM: success createSchemaCustomization - 1.855s
1:46:57 PM: info Craft config version has not changed since last sourcing. Checking for content changes since "2021-12-07 15:01:11".
1:46:58 PM: info Sourcing changes for 5 nodes.
1:46:58 PM: error "gatsby-source-craft" threw an error while running the sourceNodes lifecycle:
1:46:58 PM: Missing Gatsby node definition for remote type Element
1:46:58 PM:   552 |         }
1:46:58 PM:   553 |         // And source, if needed
1:46:58 PM: > 554 |         await sourceNodeChanges(config, { nodeEvents });
1:46:58 PM:       |         ^
1:46:58 PM:   555 |     }
1:46:58 PM:   556 |     await cache.set(`CRAFT_CONFIG_VERSION`, remoteConfigVersion);
1:46:58 PM:   557 |     await cache.set(`CRAFT_LAST_CONTENT_UPDATE`, lastUpdateTime);
1:46:59 PM: 
1:46:59 PM: 
1:46:59 PM:   Error: Missing Gatsby node definition for remote type Element
1:46:59 PM:   
1:46:59 PM:   - node-definition-helpers.ts:46 Object.getGatsbyNodeDefinition
1:46:59 PM:     [repo]/[gatsby-graphql-source-toolkit]/src/source-nodes/utils/node-definitio    n-helpers.ts:46:11

Starting to feel like we are doing something wrong? Or do we just find all edge cases? :)

@andris-sevcenko
Copy link
Contributor

"Allow listing element drafts", "Allow listing element revisions"

This needs to be enabled. Please see #61

As far as the actual error goes - can you update Gatsby Helper to 1.1.1 (just released) and run the following query in the Craft control panel?

{
  nodesUpdatedSince (since: "2021-12-07 15:01:11") {
    nodeId
    nodeType
    elementType
  }
}

Curios to see what the results are of that query.

@andreasottosson
Copy link
Author

I'm sorry Andris. I obviously should have read #61 more carefully, I though it was just the last of the three. Now everything is checked, except for Freeform.

The query returns the following (updated to Gatsby Helper 1.1.1 and Craft 3.7.25.1). Perhaps that Freeform Element is the problem?

{
  "data": {
    "nodesUpdatedSince": [
      {
        "nodeId": "8496",
        "nodeType": "levering_GlobalSet",
        "elementType": "craft\\elements\\GlobalSet"
      },
      {
        "nodeId": "25974",
        "nodeType": "viden_viden_Entry",
        "elementType": "craft\\elements\\Entry"
      },
      {
        "nodeId": "37798",
        "nodeType": "Element",
        "elementType": "Solspace\\Freeform\\Elements\\Submission"
      }
    ]
  }
}

@andris-sevcenko
Copy link
Contributor

No worries, we've all been guilty of not reading things carefully enough :)

Yeah, it's a Solspace Freeform thing, but the more I think about it, the more I think it shouldn't be on them to check that.

I'll see if I can adjust the Gatsby Helper plugin to avoid this. I'll have an answer for you in a few hours!

@andris-sevcenko
Copy link
Contributor

@andreasottosson if you update to Helper plugin 1.1.2, Freeform should no longer be bothering you :)

@andreasottosson
Copy link
Author

@andris-sevcenko Nice change there, giving it a try now. Thanks for looking into this so quickly. Hopefully now we won't have to bother you about this issue anymore :)

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

2 participants