Skip to content

[gatsby-source-contentful] TypeError: getNode is not a function #4906

@coreyward

Description

@coreyward

When a top-level Contentful resource queried for in gatsby-node.js (used to call createPage) is deleted from Contentful and gatsby develop is restarted, the following error is thrown:

success onPreBootstrap — 0.153 s
⠁ Starting to fetch data from Contentful
Fetching default locale
⠐ source and transform nodesdefault local is : en-US
⠈ source and transform nodescontentTypes fetched 17
error Plugin gatsby-source-contentful returned an error

  TypeError: getNode is not a function
  
  - gatsby-node.js:90 
    [project]/[gatsby-source-contentful]/gatsby-node.js:90:37
  
  - Array.forEach
  
  - gatsby-node.js:89 _callee$
    [project]/[gatsby-source-contentful]/gatsby-node.js:89:16
  
  - next_tick.js:112 process._tickCallback
    internal/process/next_tick.js:112:11
  

⠠ source and transform nodes

This corresponds with these lines of the gatsby-source-contentful plugin:

currentSyncData.deletedEntries.map(function (e) {
  return e.sys.id;
}).forEach(function (id) {
  return deleteNode(id, getNode(id)); // This is line 90 that's throwing the error
});

I was able to resolve the issue by removing the .cache folder and restarting. I don't know what's “upstream” of this sourceNodes call to investigate what boundActionCreators.getNode is.

It looks like this also happened to @johndewolf a few weeks ago when editing Contentful content: #4401 (comment)

Environment

  • Gatsby version (npm list gatsby): 1.9.243
  • gatsby-cli version (gatsby --version): 1.1.50
  • Node.js version: 9.9.0
  • Operating System: macOS High Sierra 10.13.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions