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

gatsby-remark-images error if using markdownCaptions: true #20000

Closed
cartant opened this issue Dec 8, 2019 · 16 comments · Fixed by #21188
Closed

gatsby-remark-images error if using markdownCaptions: true #20000

cartant opened this issue Dec 8, 2019 · 16 comments · Fixed by #21188
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@cartant
Copy link

cartant commented Dec 8, 2019

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

  1. Create a new Gatsby site using gatsby-starter-blog:

     gatsby new markdown-caption-repro https://github.com/gatsbyjs/gatsby-starter-blog
    
  2. Run yarn upgrade

  3. Specify markdownCaptions in the gatsby-remark-images block

     resolve: `gatsby-remark-images`,
     options: {
       markdownCaptions: true,
       maxWidth: 590,
       showCaptions: true,
     },
    
  4. 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 
@ornotandrew
Copy link

I can confirm this is still broken.

It looks like #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 a shouldCache 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.

@wardpeet
Copy link
Contributor

wardpeet commented Dec 9, 2019

Any idea what version this regression started?

@cartant
Copy link
Author

cartant commented Dec 9, 2019

Unfortunately not. I only started using Gatsby on Sunday - two days ago. And I'm assuming that it was a regression, as there was no mention of #19288 not solving the problem.

@ornotandrew
Copy link

@wardpeet fwiw I don't think this is necessarily a regression, at least not a recent one - I think #19288 just didn't solve the problem.

I'm also fairly new to gatsby, but it might be the case that this never worked as intended?

@LekoArts LekoArts added the type: bug An issue or pull request relating to a bug in Gatsby label Dec 16, 2019
@github-actions
Copy link

github-actions bot commented Jan 5, 2020

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 5, 2020
@cartant
Copy link
Author

cartant commented Jan 5, 2020

I guess the "not stale" label mentioned ^ is warranted here.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 6, 2020
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 26, 2020
@cartant
Copy link
Author

cartant commented Jan 26, 2020

I guess the "not stale" label mentioned ^ is warranted here.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 27, 2020
@ajfisher
Copy link

Can confirm that this is still an issue on latest version of gatsby-remark-images if you set markdownCaptions: true.

@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Feb 18, 2020
@cartant
Copy link
Author

cartant commented Feb 18, 2020

#20000 (comment)

@CanRau CanRau added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Feb 18, 2020
@raulfdm
Copy link

raulfdm commented Feb 23, 2020

Using v3.1.44, same issue :/

@shan-hua
Copy link

shan-hua commented Mar 8, 2020

Same issue in v3.1.46..

@chris-erickson
Copy link
Contributor

Who owns this code and can help move it forward, @wardpeet? We're hitting this problem too with a blog that has a lot of captions and don't really have a way around it.

@shan-hua
Copy link

shan-hua commented Mar 13, 2020

Who owns this code and can help move it forward, @wardpeet? We're hitting this problem too with a blog that has a lot of captions and don't really have a way around it.

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

@vladar
Copy link
Contributor

vladar commented Apr 16, 2020

CC @mathieudutour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants