gatsbysharpgatsby-imagegatsby-remark-image

gatsby-remark-images-remote make the build fail, how to troubleshoot the root cause?


My gatsby site https://jeff-tian.jiwai.win/ (Source code: https://github.com/Jeff-Tian/space/) uses gatsby js. It contains thousands of markdown blog posts and the building used to be smooth before I made the following change.

The images in the posts couldn't be rendered directly as they are remote images.

So I think I can download the images locally during the building phase, and found this plugin just for the purpose: https://github.com/icaraps/gatsby-remark-images-remote.

However, when met the broken link it throws. So I forked the plugin to catch the errors regarding broken links and continue building the site.

But the building still fails and I don't know why. I tried many tweaks for example configuring failOn to none to the image-sharp plugin.

enter image description here

Still no luck. You can check the failed jobs here: https://github.com/Jeff-Tian/space/actions

enter image description here

There are error logs, however, they shouldn't block the building. The error is something similar to Error: Input buffer contains unsupported image format. enter image description here

Could anyone help me troubleshoot the root cause? Is there any option from the gatsby configuration side to continue building along with these image-processing errors?


Solution

  • So I took a deep breath and started to write test cases to try to reproduce the error:

    enter image description here

    And succeeded in reproducing with the latest test case, and then by following the error trace locally I finally spotted the devil!

    The gatsby-plugin-sharp has a line of code: process.exit(1). Damn!!

    After the root cause founded, I created a PR to fix it: https://github.com/gatsbyjs/gatsby/pull/37165.

    enter image description here