craftcms / gatsby-source-craft

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

Sourcing data error #56

Closed fergusfrl closed 2 years ago

fergusfrl commented 2 years ago

Description

I am getting the error below sporadically. I get this error in ~70% of the builds. The remaining ~30% of the time the build is successful.

Steps to reproduce

  1. Run gatsby build

Additional info

Stack Trace

 ERROR #11321  PLUGIN

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

Failed to execute query LIST_footer_Node.

  468 |     if (remoteConfigVersion !== localConfigVersion || !localContentUpdateTime) {
  469 |         reporter.info("Cached content is unavailable or outdated, sourcing _all_ nodes.");
> 470 |         await sourceAllNodes(config);
      |         ^
  471 |     }
  472 |     else {
  473 |         reporter.info(`Craft config version has not changed since last sourcing. Checking for content changes since "${localContentUpdateTime}".`);

File: node_modules/gatsby-source-craft/gatsby-node.js:470:9

  Error: Failed to execute query LIST_footer_Node.

  - paginate.ts:60 Object.paginate
    [forhealth001-gatsby]/[gatsby-graphql-source-toolkit]/src/source-nodes/fetch-nodes/paginate.ts:60:13

  - runMicrotasks

  - task_queues.js:95 processTicksAndRejections
    internal/process/task_queues.js:95:5

  - fetch-lists.ts:61 fetchNodeList
    [forhealth001-gatsby]/[gatsby-graphql-source-toolkit]/src/source-nodes/fetch-nodes/fetch-lists.ts:61:20

  - fetch-lists.ts:36 Object.fetchAllNodes
    [forhealth001-gatsby]/[gatsby-graphql-source-toolkit]/src/source-nodes/fetch-nodes/fetch-lists.ts:36:24

  - create-nodes.ts:13 Object.createNodes
    [forhealth001-gatsby]/[gatsby-graphql-source-toolkit]/src/source-nodes/node-actions/create-nodes.ts:13:20

  - async Promise.all

  - source-all-nodes.ts:20 sourceAllNodes
    [forhealth001-gatsby]/[gatsby-graphql-source-toolkit]/src/source-nodes/source-all-nodes.ts:20:3

  - gatsby-node.js:470 Object.exports.sourceNodes
    [forhealth001-gatsby]/[gatsby-source-craft]/gatsby-node.js:470:9

  - api-runner-node.js:434 runAPI
    [forhealth001-gatsby]/[gatsby]/src/utils/api-runner-node.js:434:16

not finished source and transform nodes - 32.244s
not finished fetching pages_default_Entry - 31.443s
andris-sevcenko commented 2 years ago

Anything in your Craft logs when that happens?

fergusfrl commented 2 years ago

An error in the craft log

0 /var/app/current/vendor/craftcms/cms/src/base/Element.php(1736): yii\base\Component->__get('revisionCreator')

1 /var/app/current/vendor/craftcms/cms/src/gql/base/ObjectType.php(73): craft\base\Element->__get('revisionCreator')

2 /var/app/current/vendor/craftcms/cms/src/gql/types/elements/Element.php(54): craft\gql\base\ObjectType->resolve(Object(craft\elements\Entry), Array, Array, Object(GraphQL\Ty

pe\Definition\ResolveInfo))

3 /var/app/current/vendor/craftcms/cms/src/gql/types/elements/Entry.php(56): craft\gql\types\elements\Element->resolve(Object(craft\elements\Entry), Array, Array, Object(Graph

QL\Type\Definition\ResolveInfo))

4 /var/app/current/vendor/craftcms/cms/src/gql/base/ObjectType.php(47): craft\gql\types\elements\Entry->resolve(Object(craft\elements\Entry), Array, Array, Object(GraphQL\Type

\Definition\ResolveInfo))

5 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(624): craft\gql\base\ObjectType->resolveWithDirectives(Object(craft\elements\Entry), Array, Ar

ray, Object(GraphQL\Type\Definition\ResolveInfo))

6 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(550): GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError(Object(GraphQL\Type\Definit

ion\FieldDefinition), Object(GraphQL\Language\AST\FieldNode), Array, Object(craft\elements\Entry), Object(GraphQL\Type\Definition\ResolveInfo))

7 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1196): GraphQL\Executor\ReferenceExecutor->resolveField(Object(craft\gql\types\elements\Entry)

, Object(craft\elements\Entry), Object(ArrayObject), Array)

8 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1146): GraphQL\Executor\ReferenceExecutor->executeFields(Object(craft\gql\types\elements\Entry

), Object(craft\elements\Entry), Array, Object(ArrayObject))

9 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1107): GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields(Object(craft\gql\types\e

lements\Entry), Object(ArrayObject), Array, Object(craft\elements\Entry))

10 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(975): GraphQL\Executor\ReferenceExecutor->completeObjectValue(Object(craft\gql\types\elements

\Entry), Object(ArrayObject), Object(GraphQL\Type\Definition\ResolveInfo), Array, Object(craft\elements\Entry))

11 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(790): GraphQL\Executor\ReferenceExecutor->completeAbstractValue(Object(GraphQL\Type\Definitio

n\InterfaceType), Object(ArrayObject), Object(GraphQL\Type\Definition\ResolveInfo), Array, Object(craft\elements\Entry))

12 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(655): GraphQL\Executor\ReferenceExecutor->completeValue(Object(GraphQL\Type\Definition\Interf

aceType), Object(ArrayObject), Object(GraphQL\Type\Definition\ResolveInfo), Array, Object(craft\elements\Entry))

13 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(888): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError(Object(GraphQL\Type\Defi

nition\InterfaceType), Object(ArrayObject), Object(GraphQL\Type\Definition\ResolveInfo), Array, Object(craft\elements\Entry))

14 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(762): GraphQL\Executor\ReferenceExecutor->completeListValue(Object(GraphQL\Type\Definition\Li

stOfType), Object(ArrayObject), Object(GraphQL\Type\Definition\ResolveInfo), Array, Array)

15 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(655): GraphQL\Executor\ReferenceExecutor->completeValue(Object(GraphQL\Type\Definition\ListOf

Type), Object(ArrayObject), Object(GraphQL\Type\Definition\ResolveInfo), Array, Array)

16 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(557): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError(Object(GraphQL\Type\Defi

nition\ListOfType), Object(ArrayObject), Object(GraphQL\Type\Definition\ResolveInfo), Array, Array)

17 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1196): GraphQL\Executor\ReferenceExecutor->resolveField(Object(GraphQL\Type\Definition\Object

Type), NULL, Object(ArrayObject), Array)

18 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(264): GraphQL\Executor\ReferenceExecutor->executeFields(Object(GraphQL\Type\Definition\Object

Type), NULL, Array, Object(ArrayObject))

19 /var/app/current/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(215): GraphQL\Executor\ReferenceExecutor->executeOperation(Object(GraphQL\Language\AST\Operat

ionDefinitionNode), NULL)

20 /var/app/current/vendor/webonyx/graphql-php/src/Executor/Executor.php(156): GraphQL\Executor\ReferenceExecutor->doExecute()

21 /var/app/current/vendor/webonyx/graphql-php/src/GraphQL.php(162): GraphQL\Executor\Executor::promiseToExecute(Object(GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter), O

bject(GraphQL\Type\Schema), Object(GraphQL\Language\AST\DocumentNode), NULL, Array, Array, 'LIST_jobs_defau...', NULL)

22 /var/app/current/vendor/webonyx/graphql-php/src/GraphQL.php(94): GraphQL\GraphQL::promiseToExecute(Object(GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter), Object(Graph

QL\Type\Schema), 'query NODE_jobs...', NULL, Array, Array, 'LIST_jobs_defau...', NULL, Array)

23 /var/app/current/vendor/craftcms/cms/src/services/Gql.php(544): GraphQL\GraphQL::executeQuery(Object(GraphQL\Type\Schema), 'query NODE_jobs...', NULL, Array, Array, 'LIST_j

obs_defau...', NULL, Array)

24 /var/app/current/vendor/craftcms/cms/src/controllers/GraphqlController.php(172): craft\services\Gql->executeQuery(Object(craft\models\GqlSchema), 'query NODE_jobs...', Arra

y, 'LIST_jobs_defau...', false)

25 [internal function]: craft\controllers\GraphqlController->actionApi()

26 /var/app/current/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

27 /var/app/current/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)

28 /var/app/current/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('api', Array)

29 /var/app/current/vendor/craftcms/cms/src/web/Application.php(277): yii\base\Module->runAction('graphql/api', Array)

30 /var/app/current/vendor/yiisoft/yii2/web/Application.php(104): craft\web\Application->runAction('graphql/api', Array)

31 /var/app/current/vendor/craftcms/cms/src/web/Application.php(262): yii\web\Application->handleRequest(Object(craft\web\Request))

32 /var/app/current/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))

33 /var/app/current/public/index.php(26): yii\base\Application->run()

34 {main}

andris-sevcenko commented 2 years ago

Just fixed the above stack trace for the next Craft 3.7 release. I'll let you know when it's out.

To get the fix early, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop#6eb2613f99444a94728103ea7eac45469b4576b1",
  "...": "..."
}

Then run composer update.

brandonkelly commented 2 years ago

Craft 3.7.18 is out now with that fix.

fergusfrl commented 2 years ago

@brandonkelly we are still experiencing this issue. We have upgraded to Craft 3.7.18 and will still often receive the below error during builds.

Do you have any recommendations for how to avoid this problem?

15:44:11 PM:
Cloning into '/usr/src/app/www'...

15:44:13 PM:
Using node version from .nvmrc: v16.10.0

15:44:13 PM:
Installing node version v16.10.0

15:44:13 PM:
Downloading and installing node v16.10.0...

15:44:16 PM:
Now using node v16.10.0 (npm v7.24.0)

15:44:33 PM:
npm

15:44:33 PM:
 WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained

15:44:33 PM:
npm

15:44:33 PM:
WARN

15:44:33 PM:
deprecated

15:44:33 PM:
 urix@0.1.0: Please see https://github.com/lydell/urix#deprecated

15:44:33 PM:
npm

15:44:33 PM:
 WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated

15:44:33 PM:
npm

15:44:33 PM:
 WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

15:44:34 PM:
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.

15:44:34 PM:
npm

15:44:34 PM:
 WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

15:44:34 PM:
npm

15:44:34 PM:
 WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'

15:44:34 PM:
npm

15:44:34 PM:
 WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

15:44:34 PM:
npm

15:44:34 PM:
 WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained

15:44:35 PM:
npm

15:44:35 PM:
 WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'

15:44:35 PM:
npm

15:44:35 PM:
 WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.

15:44:37 PM:
npm

15:44:37 PM:
 WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.

15:44:43 PM:

added 2310 packages in 18s

15:44:43 PM:

251 packages are looking for funding
  run `npm fund` for details

15:44:47 PM:
From https://gitlab.com/batchnz/work/forhealth001-gatsby
 * branch            133-create-link-list-component -> FETCH_HEAD

15:44:47 PM:
HEAD is now at ef16564 feat(link-list): change class on heading and index

15:44:48 PM:
Already on '133-create-link-list-component'

15:44:48 PM:
Your branch is up to date with 'origin/133-create-link-list-component'.

15:44:49 PM:
Node version v16.10.0

15:44:50 PM:
Gatsby version Gatsby CLI version: 3.12.0

15:44:50 PM:
  Note: this is the Gatsby version for the site at: /usr/src/app/www

15:44:50 PM:
Gatsby version: 3.12.0

15:44:50 PM:
BUILDS

15:44:53 PM:
success open and validate gatsby-configs, load plugins - 0.755s

15:44:53 PM:
success onPreInit - 0.033s

15:44:53 PM:
success initialize cache - 0.009s

15:44:53 PM:
success copy gatsby files - 0.052s

15:44:55 PM:
success Compiling Gatsby Functions - 1.904s

15:44:55 PM:
info Clearing previous fragments.

15:44:55 PM:
info Writing default fragments.

15:45:04 PM:
success onPreBootstrap - 11.023s

15:45:04 PM:
info Found 0 additional fragments

15:45:09 PM:
success createSchemaCustomization - 5.182s

15:45:09 PM:
info Checking Craft config version.

15:45:10 PM:
info Cached content is unavailable or outdated, sourcing _all_ nodes.

15:45:12 PM:
success fetching practicesIndex_practicesIndex_Entry - 1.805s

15:45:13 PM:
success fetching contact_contact_Entry - 1.899s

15:45:14 PM:
success fetching sitemap_sitemap_Entry - 3.450s

15:45:14 PM:
success fetching referAGp_referAGp_Entry - 3.511s

15:45:16 PM:
success fetching social_GlobalSet - 4.811s

15:45:16 PM:
success fetching documents_Asset - 4.830s

15:45:16 PM:
success fetching User - 5.170s

15:45:19 PM:
success fetching practicesServices_default_Entry - 8.772s

15:45:20 PM:
success fetching jobsCategories_default_Entry - 9.246s

15:45:20 PM:
success fetching jobsTypes_default_Entry - 9.313s

15:45:21 PM:
success fetching states_default_Entry - 10.402s

15:45:21 PM:
success fetching recruiter_default_Entry - 10.783s

15:45:23 PM:
success fetching jobs_default_Entry - 11.833s

15:45:23 PM:
success fetching practices_default_Entry - 12.723s

15:45:25 PM:
success fetching images_Asset - 13.745s

15:45:40 PM:
success fetching pages_default_Entry - 29.530s

15:45:40 PM:
ERROR "gatsby-source-craft" threw an error while running the sourceNodes lifecycle:

15:45:40 PM:
  468 |     if (remoteConfigVersion !== localConfigVersion || !localContentUpdateTime) {

15:45:40 PM:
Failed to execute query LIST_pages_default_Entry.

15:45:40 PM:
  471 |     }

15:45:40 PM:
      |         ^

15:45:40 PM:
  472 |     else {

15:45:40 PM:
  469 |         reporter.info("Cached content is unavailable or outdated, sourcing _all_ nodes.");

15:45:40 PM:
> 470 |         await sourceAllNodes(config);

15:45:40 PM:
  473 |         reporter.info(`Craft config version has not changed since last sourcing. Checking for content changes since "${localContentUpdateTime}".`);

15:45:40 PM:
  Error: Failed to execute query LIST_pages_default_Entry.

15:45:40 PM:
  - task_queues:96 processTicksAndRejections

15:45:40 PM:
  - paginate.ts:60 Object.paginate

15:45:40 PM:
    node:internal/process/task_queues:96:5

15:45:40 PM:
    [www]/[gatsby-graphql-source-toolkit]/src/source-nodes/fetch-nodes/paginate.    ts:60:13

15:45:40 PM:
    [www]/[gatsby-graphql-source-toolkit]/src/source-nodes/fetch-nodes/fetch-lis    ts.ts:61:20

15:45:40 PM:
  - fetch-lists.ts:61 fetchNodeList

15:45:40 PM:
  - fetch-lists.ts:36 Object.fetchAllNodes

15:45:40 PM:
    [www]/[gatsby-graphql-source-toolkit]/src/source-nodes/fetch-nodes/fetch-lis    ts.ts:36:24

15:45:40 PM:
  - create-nodes.ts:13 Object.createNodes

15:45:40 PM:
  - async Promise.all

15:45:40 PM:
  - source-all-nodes.ts:20 sourceAllNodes

15:45:40 PM:
    [www]/[gatsby-graphql-source-toolkit]/src/source-nodes/node-actions/create-n    odes.ts:13:20

15:45:40 PM:
  - api-runner-node.js:434 runAPI

15:45:40 PM:
  - gatsby-node.js:470 Object.exports.sourceNodes

15:45:40 PM:
    [www]/[gatsby-graphql-source-toolkit]/src/source-nodes/source-all-nodes.ts:2    0:3

15:45:40 PM:
    [www]/[gatsby-source-craft]/gatsby-node.js:470:9

15:45:40 PM:
    [www]/[gatsby]/src/utils/api-runner-node.js:434:16

15:45:40 PM:
not finished fetching footerNav_default_Entry - 29.308s

15:45:40 PM:
not finished fetching headerNav_default_Entry - 29.263s

15:45:40 PM:
not finished source and transform nodes - 30.643s

15:45:40 PM:
not finished fetching home_home_Entry - 29.481s

15:45:41 PM:
ERROR Failed to compile: Error: Exited with code 1
andris-sevcenko commented 2 years ago

If a query just failed with no more information on build step, it most likely failed no Craft side, so - same question as before -anything in your Craft logs?