Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node.id to cache id to avoid cache collissions if the nodes have identical content fixes #4385 #4388

Merged
merged 2 commits into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ date: \\"2017-09-18T23:19:51.246Z\\"
---
Where oh where is my little pony?
",
"contentDigest": "8062733a090dc2fca383c268ae549f71",
"contentDigest": "c28ae5f9cd5d74e0697ce8a0e8ff5715",
"type": "MarkdownRemark",
},
"parent": "whatever",
Expand Down Expand Up @@ -50,7 +50,7 @@ date: \\"2017-09-18T23:19:51.246Z\\"
---
Where oh where is my little pony?
",
"contentDigest": "8062733a090dc2fca383c268ae549f71",
"contentDigest": "c28ae5f9cd5d74e0697ce8a0e8ff5715",
"type": "MarkdownRemark",
},
"parent": "whatever",
Expand Down Expand Up @@ -108,7 +108,7 @@ Sed eu gravida mauris. Suspendisse potenti. Praesent sit amet egestas mi, sed he

Sed bibendum sem iaculis, pellentesque leo sed, imperdiet ante. Sed consequat mattis dui nec pretium. Donec vel consectetur est. Nam sagittis, libero vitae pretium pharetra, velit est dignissim erat, at cursus quam massa vitae ligula. Suspendisse potenti. In hac habitasse platea dictumst. Donec sit amet finibus justo. Mauris ante dolor, pulvinar vitae feugiat eu, rhoncus nec diam. In ut accumsan diam, faucibus fringilla odio. Nunc id ultricies turpis. Quisque justo quam, tristique sit amet interdum quis, facilisis at mi. Fusce porttitor vel sem ut condimentum. Praesent at libero congue, vulputate elit ut, rhoncus erat.
",
"contentDigest": "5614c9ff7407c62db422b1da90a0e326",
"contentDigest": "f254262a22000e42becc065aab25e3a3",
"type": "MarkdownRemark",
},
"parent": "whatever",
Expand Down Expand Up @@ -152,7 +152,7 @@ Sed eu gravida mauris. Suspendisse potenti. Praesent sit amet egestas mi, sed he

Sed bibendum sem iaculis, pellentesque leo sed, imperdiet ante. Sed consequat mattis dui nec pretium. Donec vel consectetur est. Nam sagittis, libero vitae pretium pharetra, velit est dignissim erat, at cursus quam massa vitae ligula. Suspendisse potenti. In hac habitasse platea dictumst. Donec sit amet finibus justo. Mauris ante dolor, pulvinar vitae feugiat eu, rhoncus nec diam. In ut accumsan diam, faucibus fringilla odio. Nunc id ultricies turpis. Quisque justo quam, tristique sit amet interdum quis, facilisis at mi. Fusce porttitor vel sem ut condimentum. Praesent at libero congue, vulputate elit ut, rhoncus erat.
",
"contentDigest": "5614c9ff7407c62db422b1da90a0e326",
"contentDigest": "f254262a22000e42becc065aab25e3a3",
"type": "MarkdownRemark",
},
"parent": "whatever",
Expand Down
13 changes: 4 additions & 9 deletions packages/gatsby-transformer-remark/src/on-node-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,12 @@ module.exports = async function onCreateNode(
})
}

const contentDigest = crypto
.createHash(`md5`)
.update(JSON.stringify(data))
.digest(`hex`)
const markdownNode = {
id: `${node.id} >>> MarkdownRemark`,
children: [],
parent: node.id,
internal: {
content,
contentDigest,
type: `MarkdownRemark`,
},
}
Expand All @@ -57,10 +52,10 @@ module.exports = async function onCreateNode(

markdownNode.excerpt = data.excerpt

// Add path to the markdown file path
if (node.internal.type === `File`) {
markdownNode.fileAbsolutePath = node.absolutePath
}
markdownNode.internal.contentDigest = crypto
.createHash(`md5`)
.update(JSON.stringify(markdownNode))
.digest(`hex`)

createNode(markdownNode)
createParentChildLink({ parent: node, child: markdownNode })
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/schema/run-sift.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { trackInlineObjectsInRootNode } = require(`./node-tracking`)
const enhancedNodeCache = new Map()
const enhancedNodeCacheId = ({ node, args }) =>
node && node.internal && node.internal.contentDigest
? `${node.internal.contentDigest}${JSON.stringify(args)}`
? `${node.id}${node.internal.contentDigest}${JSON.stringify(args)}`
: null

function awaitSiftField(fields, node, k) {
Expand Down