From b3c8a459710be067633887b7039bf99b0fd1cdbc Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Wed, 21 Feb 2018 13:12:01 -0800 Subject: [PATCH] Check that the node exists before trying to access its id fixes #4162 (#4173) --- .../src/internal-plugins/query-runner/page-query-runner.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/src/internal-plugins/query-runner/page-query-runner.js b/packages/gatsby/src/internal-plugins/query-runner/page-query-runner.js index f4e0f0af46b61..e1691a638f94b 100644 --- a/packages/gatsby/src/internal-plugins/query-runner/page-query-runner.js +++ b/packages/gatsby/src/internal-plugins/query-runner/page-query-runner.js @@ -123,10 +123,12 @@ const findDirtyIds = actions => { return actions.reduce((dirtyIds, action) => { const node = action.payload - // find invalid pagesAndLayouts + if (!node || !node.id || !node.internal.type) return dirtyIds + + // Find pagesAndLayouts that depend on this node so are now dirty. dirtyIds = dirtyIds.concat(state.componentDataDependencies.nodes[node.id]) - // Find invalid connections + // Find connections that depend on this node so are now invalid. dirtyIds = dirtyIds.concat( state.componentDataDependencies.connections[node.internal.type] )