smakosh / gatsby-source-dribbble

Load your Dribbble shots into your Gatsby website
https://www.npmjs.com/package/gatsby-source-dribbble
MIT License
11 stars 4 forks source link

Gatsby v4.5.4 getting "gatsby-source-dribbble" threw an error while running the sourceNodes lifecycle" #19

Closed MadMaxMcKinney closed 2 years ago

MadMaxMcKinney commented 2 years ago

Did an upgrade today and got this error, although I think I managed to build successfully once after upgrading everything and now I just get this:

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

Cannot read properties of undefined (reading 'type')

  TypeError: Cannot read properties of undefined (reading 'type')

  - public.js:904 Object.actions.touchNode
    [max-mckinney-gatsby]/[gatsby]/src/redux/actions/public.js:904:41

  - call-deferred-api.ts:17 callRealApi
    [max-mckinney-gatsby]/[gatsby]/src/utils/call-deferred-api.ts:17:20

  - actions.ts:26 callApi
    [max-mckinney-gatsby]/[gatsby]/src/state-machines/develop/actions.ts:26:6

  - interpreter.js:770 Interpreter.exec
    [max-mckinney-gatsby]/[xstate]/lib/interpreter.js:770:16

  - interpreter.js:204 Interpreter.execute
    [max-mckinney-gatsby]/[xstate]/lib/interpreter.js:204:14

  - interpreter.js:230 Interpreter.update
    [max-mckinney-gatsby]/[xstate]/lib/interpreter.js:230:12

  - interpreter.js:110
    [max-mckinney-gatsby]/[xstate]/lib/interpreter.js:110:15

  - scheduler.js:69 Scheduler.process
    [max-mckinney-gatsby]/[xstate]/lib/scheduler.js:69:7

  - scheduler.js:48 Scheduler.schedule
    [max-mckinney-gatsby]/[xstate]/lib/scheduler.js:48:10

  - interpreter.js:104 Interpreter.send
    [max-mckinney-gatsby]/[xstate]/lib/interpreter.js:104:23

  - interpreter.js:1114 callback
    [max-mckinney-gatsby]/[xstate]/lib/interpreter.js:1114:13

  - listen-for-mutations.ts:6 callback
    [max-mckinney-gatsby]/[gatsby]/src/services/listen-for-mutations.ts:6:5

  - mett.ts:44 forEach
    [max-mckinney-gatsby]/[gatsby]/src/utils/mett.ts:44:11

  - Set.forEach

  - mett.ts:43 Object.emit
    [max-mckinney-gatsby]/[gatsby]/src/utils/mett.ts:43:17

  - api-runner-node.js:120
    [max-mckinney-gatsby]/[gatsby]/src/utils/api-runner-node.js:120:20

Here are my packages as well:

"dependencies": {
    "@tailwindcss/typography": "^0.5.0",
    "autoprefixer": "^10.4.2",
    "gatsby": "^4.5.4",
    "gatsby-image": "^3.11.0",
    "gatsby-plugin-google-analytics": "^4.5.0",
    "gatsby-plugin-image": "^2.5.2",
    "gatsby-plugin-layout": "^3.5.0",
    "gatsby-plugin-manifest": "^4.5.2",
    "gatsby-plugin-postcss": "^5.5.0",
    "gatsby-plugin-react-helmet": "^5.5.0",
    "gatsby-plugin-sharp": "^4.5.2",
    "gatsby-plugin-styled-components": "^5.5.0",
    "gatsby-remark-images": "^6.5.2",
    "gatsby-remark-images-medium-zoom": "^1.7.0",
    "gatsby-remark-responsive-iframe": "^5.5.0",
    "gatsby-source-dribbble": "^2.1.4",
    "gatsby-source-filesystem": "^4.5.2",
    "gatsby-source-medium": "^4.5.0",
    "gatsby-transformer-remark": "^5.5.2",
    "gatsby-transformer-sharp": "^4.5.0",
    "npm": "^8.3.2",
    "postcss": "^8.4.5",
    "prop-types": "^15.8.1",
    "react": "^17.0.2",
    "react-countup": "^6.1.1",
    "react-dom": "^17.0.2",
    "react-helmet": "^6.1.0",
    "react-masonry-component": "^6.3.0",
    "styled-components": "^5.3.3",
    "tailwindcss": "^3.0.15",
    "typeface-barlow": "^1.1.13",
    "typeface-inter": "^3.18.1",
    "typeface-rubik": "^1.1.13",
    "typeface-source-sans-pro": "^1.1.13"
  },
reaganchisholm commented 2 years ago

I was getting the same issue as @MadMaxMcKinney above after updating my dependencies.

It seems it was related to how the plugin was fetching the cached Dribbble shots. Which is why you can get it to go through on a fresh install or after removing the cache folder.

After some digging, I found the culprit under createFileNode.js and updated these lines from:

if (cacheMediaData) {
    fileNodeID = cacheMediaData.fileNodeID
    touchNode({
      nodeId: cacheMediaData.fileNodeID,
    })
}

to

if (cacheMediaData) {
    fileNodeID = cacheMediaData.fileNodeID;
    touchNode({
      id: cacheMediaData.fileNodeID,
      internal: {
        type: "DribbbleShot"
      }
    });
  } 

and that seemed to solve the issue in my build. Hope that helps. I've also opened a PR with those changes.

scottbaggett commented 2 years ago

Can we get this PR merged? I am waiting for this fix as well.

smakosh commented 2 years ago

Can we get this PR merged? I am waiting for this fix as well.

Merged, sorry was busy these recent months.