From da9a8f52e37c1e995198e19dafa1542d20807cca Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Tue, 18 Apr 2023 23:54:28 -0700 Subject: [PATCH] fix(gatsby-source-contentful): don't call `createNode` on `null` (#37958) --- .../gatsby-source-contentful/src/normalize.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/gatsby-source-contentful/src/normalize.js b/packages/gatsby-source-contentful/src/normalize.js index 41c42c601f64c..6ef8a70e03322 100644 --- a/packages/gatsby-source-contentful/src/normalize.js +++ b/packages/gatsby-source-contentful/src/normalize.js @@ -787,14 +787,20 @@ export const createNodesForContentType = async ({ }) entryNodes.forEach((entryNode, index) => { - create(entryNode, () => { - entryNodes[index] = undefined - }) + // entry nodes may be undefined here if the node was previously already created + if (entryNode) { + create(entryNode, () => { + entryNodes[index] = undefined + }) + } }) childrenNodes.forEach((entryNode, index) => { - create(entryNode, () => { - childrenNodes[index] = undefined - }) + // entry nodes may be undefined here if the node was previously already created + if (entryNode) { + create(entryNode, () => { + childrenNodes[index] = undefined + }) + } }) })