gatsby: gatsby-remark-images error if using markdownCaptions: true
Description
There seems to have been a regression and an error similar to the one reported in #16703 and fixed in #19288 is effected if markdownCaptions: true
is specified in the gatsby-remark-images
configuration within gatsby-config.js
The error is the same, but the reported call stack is a little different.
Steps to reproduce
-
Create a new Gatsby site using
gatsby-starter-blog
:gatsby new markdown-caption-repro https://github.com/gatsbyjs/gatsby-starter-blog
-
Run
yarn upgrade
-
Specify
markdownCaptions
in thegatsby-remark-images
blockresolve: `gatsby-remark-images`, options: { markdownCaptions: true, maxWidth: 590, showCaptions: true, },
-
Run
yarn develop
Expected result
The page content should be generated and the development site should be available.
Actual result
ERROR
UNHANDLED REJECTION Cannot read property 'contentDigest' of undefined
TypeError: Cannot read property 'contentDigest' of undefined
- extend-node-type.js:59 htmlAstCacheKey
[narkdown-caption-repro]/[gatsby-transformer-remark]/extend-node-type.js:59:87
- extend-node-type.js:318 getHTMLAst
[narkdown-caption-repro]/[gatsby-transformer-remark]/extend-node-type.js:318:41
- extend-node-type.js:343 Object.getHTML [as generateHTML]
[narkdown-caption-repro]/[gatsby-transformer-remark]/extend-node-type.js:343:27
- index.js:150 getImageCaption
[narkdown-caption-repro]/[gatsby-remark-images]/index.js:150:21
- index.js:301 generateImagesAndUpdateNode$
[narkdown-caption-repro]/[gatsby-remark-images]/index.js:301:52
not finished run queries - 1.251s
not finished Generating image thumbnails - 1.383s
Environment
System:
OS: Windows 10 10.0.17763
CPU: (4) x64 Intel(R) Celeron(R) N4100 CPU @ 1.10GHz
Binaries:
Node: 12.11.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.21.0 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.11.3 - C:\Program Files\nodejs\npm.CMD
Languages:
Python: 2.7.16 - /c/Programs/Python27/python
Browsers:
Edge: 44.17763.831.0
npmPackages:
gatsby: ^2.18.4 => 2.18.7
gatsby-image: ^2.2.34 => 2.2.34
gatsby-plugin-feed: ^2.3.22 => 2.3.23
gatsby-plugin-google-analytics: ^2.1.29 => 2.1.29
gatsby-plugin-manifest: ^2.2.30 => 2.2.31
gatsby-plugin-offline: ^3.0.24 => 3.0.27
gatsby-plugin-react-helmet: ^3.1.16 => 3.1.16
gatsby-plugin-sharp: ^2.3.4 => 2.3.5
gatsby-plugin-typography: ^2.3.18 => 2.3.18
gatsby-remark-copy-linked-files: ^2.1.31 => 2.1.31
gatsby-remark-images: ^3.1.34 => 3.1.35
gatsby-remark-prismjs: ^3.3.25 => 3.3.25
gatsby-remark-responsive-iframe: ^2.2.28 => 2.2.28
gatsby-remark-smartypants: ^2.1.17 => 2.1.17
gatsby-source-filesystem: ^2.1.39 => 2.1.40
gatsby-transformer-remark: ^2.6.38 => 2.6.39
gatsby-transformer-sharp: ^2.3.6 => 2.3.7
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 16 (3 by maintainers)
Hi, I’ve been waiting for a week and made some changes finally by myself. I’ve just sent a PR #22256, we will see if it can be merged up, or someone may have a better solution
https://github.com/gatsbyjs/gatsby/issues/20000#issuecomment-578495405
I can confirm this is still broken.
It looks like https://github.com/gatsbyjs/gatsby/pull/19288 didn’t completely fix the problem, since we make a call to
getHTMLAst
which immediately encounters the same problem.Even if we were to use the same check one level deeper, we would just encounter the problem again on the next level.
It seems like this might have just gotten a bit messy, and could possibly use some re-thinking around what should be cached and what shouldn’t. Maybe
markdownNode
itself could carry ashouldCache
property to avoid doing checks at each level?Another thing to consider is that the tests in
gatsby-remark-images
didn’t catch this, since the problematic piece of code is mocked out.