Skip to content

Commit

Permalink
fix(gatsby-transformer-remark): Check key before trying to get cache (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudutour authored and sidharthachatterjee committed Nov 13, 2019
1 parent 67d3ee8 commit 8b8293d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/gatsby-transformer-remark/src/extend-node-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ module.exports = (
}

async function getHTML(markdownNode) {
const cachedHTML = await cache.get(htmlCacheKey(markdownNode))
const shouldCache = markdownNode && markdownNode.internal
const cachedHTML =
shouldCache && (await cache.get(htmlCacheKey(markdownNode)))
if (cachedHTML) {
return cachedHTML
} else {
Expand All @@ -340,8 +342,11 @@ module.exports = (
allowDangerousHTML: true,
})

// Save new HTML to cache and return
cache.set(htmlCacheKey(markdownNode), html)
if (shouldCache) {
// Save new HTML to cache
cache.set(htmlCacheKey(markdownNode), html)
}

return html
}
}
Expand Down

0 comments on commit 8b8293d

Please sign in to comment.