Skip to content

Commit

Permalink
Actually traverse up tree + detect potential problem with node links
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Apr 28, 2017
1 parent 442908b commit a3b3f6a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/gatsby/lib/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,20 @@ module.exports = () => {
const staleNodes = _.values(state.nodes).filter(node => {
// Find the root node.
let rootNode = node
while (getNode(rootNode.parent) !== undefined) {
rootNode = getNode(node.parent)
let whileCount = 0
while (
rootNode.parent &&
getNode(rootNode.parent) !== undefined &&
whileCount < 101
) {
rootNode = getNode(rootNode.parent)
whileCount += 1
if (whileCount > 100) {
console.log(
"It looks like you have a node that's set its parent as itself",
rootNode
)
}
}

return !_.includes(touchedNodes, rootNode.id)
Expand Down

0 comments on commit a3b3f6a

Please sign in to comment.