The following error occasionally occurs on both build and develop after content has been changed in WordPress:
...
success createSchemaCustomization - 3.573s
⠀
info gatsby-source-wordpress update user joesmallwood (#1)
error Cannot destructure property 'id' of 'undefined' as it is undefined.
...
This doesn't happen all the time and I've not been able to pin down exactly which content changes cause the error. After clearing the cache everything runs smoothly.
Private reproduction (@TylerBarnes has access): https://github.com/woodwoerk/nuori-fi-2020
Full log:
Starting: Build Gatsby
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.164.2
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
npm run build
========================== Starting Command Output ===========================
/bin/bash --noprofile --norc /home/vsts/work/_temp/c8765797-b160-4fb5-9a3c-19a7fcc1f672.sh
> [email protected] build /home/vsts/work/1/s
> gatsby build
success open and validate gatsby-configs - 0.038s
success load plugins - 1.432s
success onPreInit - 0.010s
success delete html and css files from previous builds - 0.036s
success initialize cache - 0.005s
success copy gatsby files - 0.040s
success onPreBootstrap - 0.009s
success gatsby-source-wordpress diff schemas - 1.091s
success gatsby-source-wordpress ingest WPGraphQL schema - 1.187s
success createSchemaCustomization - 3.573s
⠀
info gatsby-source-wordpress update user joesmallwood (#1)
error Cannot destructure property 'id' of 'undefined' as it is undefined.
TypeError: Cannot destructure property 'id' of 'undefined' as it is undefined.
- process-node.js:129
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/create-nodes/p rocess-node.js:129:5
- Array.find
- process-node.js:128
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/create-nodes/p rocess-node.js:128:41
- Array.filter
- process-node.js:127 fetchNodeHtmlImageMediaItemNodes
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/create-nodes/p rocess-node.js:127:86
- task_queues.js:97 processTicksAndRejections
internal/process/task_queues.js:97:5
- process-node.js:315 async replaceNodeHtmlImages
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/create-nodes/p rocess-node.js:315:44
- process-node.js:530 async processNodeString
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/create-nodes/p rocess-node.js:530:18
- process-node.js:566 async processNode
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/create-nodes/p rocess-node.js:566:31
- update.js:194 async createSingleNode
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/update-nodes/w p-actions/update.js:194:25
- update.js:140 async fetchAndCreateSingleNode
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/update-nodes/w p-actions/update.js:140:7
- update.js:348 async wpActionUPDATE
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/update-nodes/w p-actions/update.js:348:7
- index.js:104 async handleWpActions
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/update-nodes/w p-actions/index.js:104:7
- index.js:137 async fetchAndRunWpActions
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/update-nodes/w p-actions/index.js:137:7
- fetch-node-updates.js:65 async fetchAndApplyNodeUpdates
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/update-nodes/f etch-node-updates.js:65:7
- index.js:49 async sourceNodes
[s]/[gatsby-source-wordpress-experimental]/steps/source-nodes/index.js:49:7
error gatsby-source-wordpress
Encountered a critical error when running the sourceNodes.sourceNodes build step.
See above for more information.
not finished source and transform nodes - 3.712s
not finished gatsby-source-wordpress pull updates since last build - 3.640s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `gatsby build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vsts/work/1/.npm/_logs/2020-07-16T09_30_32_580Z-debug.log
##[error]Bash exited with code '1'.
Finishing: Build Gatsby
Just played around with a few simple content changes to see what triggers this:
Download link to the latest successful build's .cache and public folders for reproduction: https://we.tl/t-G6GaqiiDXN
Since the above build output was generated a few blocks containing an image and text were deleted, which now causes the build error.
To confirm, this is happening:
Does some existing image + text group still exist on the site, or are you deleting the only instance of it ?
I only deleted a block from a page (so the instance), the media file still exists on the site
Hi @woodwoerk , just so you know I haven't forgotten about this! I believe I've narrowed down what's causing it and I'm working on a fix. I'll keep you posted. Thanks for your patience!
I believe I've added a fix in [email protected]. It's hard to know for sure as I can't seem to reproduce this, but please try it out and let me know if you're still running into this
Thanks @TylerBarnes ! I've upgraded to 1.0.10, I'll stress test it with some content changes today
Dang it just happened again, exactly the same output on the CI with a clean cache after upgrading the source plugin
"gatsby-source-wordpress-experimental": "1.0.10",Here's what I changed:
How can I help debug this? Would it help if you had access to WordPress and the CI logs?
Just replicated this again locally. Oddly it doesn't seem to matter which content is added or removed, but seems to always fail on the third build after clearing the cache 😄
...
success createSchemaCustomization - 4.971s
⠀
info gatsby-source-wordpress update user joesmallwood (#1)
info gatsby-source-wordpress update post Krista Kosonen - Aliquam lorem
⠀
info content changed
success gatsby-source-wordpress pull updates since last build - 8.822s
...
success createSchemaCustomization - 4.427s
⠀
info gatsby-source-wordpress update user joesmallwood (#1)
⠀
ERROR
Cannot destructure property 'id' of 'undefined' as it is undefined.
If I don't make any content changes in WordPress there's no problems on the third or following builds
Thanks for the clear steps! I'll take another look today. I have an idea of what it is but if I can reproduce it'll be a lot easier to know that I fixed it. Thanks again!
ooo! I was finally able to reproduce using v1.0.10, I'm not able to reproduce in v1.0.12 though. Can you try updating to latest to see if you still have this issue? in 1.0.11 and 1.0.12 I did some work that makes caching in this area of code more reliable (for images in html) so I'm wondering if fixing those other bugs happened to fix this one as well.
Woooo! I’m unable to reproduce this now (with plenty of content changes between builds) 🎉
Thanks a bunch man, I can’t begin to imagine the complexity of the cache management here, great work!
Yes!! Great to hear :D Let me know if you run into anything else. I'm slowly chipping my way through all the tickets here. It will be stable soon!