gatsby: [bug]: potrace fails randomly with "cannot read property bitmap of undefined"
Running gatsby develop
works most of the time, but I randomly get this error. It seems that I’m more likely to get the error after running gatsby clean
. Today I ran gatsby develop
3 times in a row with no changes to anything. The first 2 times I got this error and the 3rd time it worked.
Generating image thumbnails [==============================] 5/5 0.1 secs 100%
error UNHANDLED EXCEPTION
TypeError: Cannot read property 'bitmap' of undefined
- Potrace.js:1000 Potrace._processLoadedImage
[blog]/[potrace]/lib/Potrace.js:1000:35
- Potrace.js:1046 Jimp.<anonymous>
[blog]/[potrace]/lib/Potrace.js:1046:14
- index.js:85 Jimp.throwError
[blog]/[jimp]/index.js:85:44
- index.js:298
[blog]/[jimp]/index.js:298:44
- png.js:81 exports.PNG.<anonymous>
[blog]/[pngjs]/lib/png.js:81:7
- parser-async.js:34 module.exports.ParserAsync._handleError
[blog]/[pngjs]/lib/parser-async.js:34:8
- parser.js:50 module.exports.Parser._parseSignature
[blog]/[pngjs]/lib/parser.js:50:12
- chunkstream.js:174 module.exports.ChunkStream._processRead
[blog]/[pngjs]/lib/chunkstream.js:174:13
- chunkstream.js:193 module.exports.ChunkStream._process
[blog]/[pngjs]/lib/chunkstream.js:193:14
- chunkstream.js:61 module.exports.ChunkStream.write
[blog]/[pngjs]/lib/chunkstream.js:61:8
- chunkstream.js:74 module.exports.ChunkStream.end
[blog]/[pngjs]/lib/chunkstream.js:74:10
- png.js:98 exports.PNG.PNG.end
[blog]/[pngjs]/lib/png.js:98:16
- png.js:88 exports.PNG.PNG.parse
[blog]/[pngjs]/lib/png.js:88:8
- index.js:297 Jimp.parseBitmap
[blog]/[jimp]/index.js:297:17
- index.js:202
[blog]/[jimp]/index.js:202:29
- read_file_context.js:53 FSReqWrap.readFileAfterClose [as oncomplete]
internal/fs/read_file_context.js:53:3
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 22 (10 by maintainers)
I had this issue in a project querying Contentful images. I simple change
GatsbyImageSharpFluid_tracedSVG
toGatsbyImageSharpFluid
and the issue seems to be solved.remove tracedSVG with gatsby.config.js
@abheist’s solution worked for me. Thank you!
I stopped using the tracedSVG option and replaced it with Blurred
— with
Genius
Solution: remove all
.webp
and.svg
(or any other new formats I guess) from your build content. I made copies from.webp
and.svg
into.png
, and kept the original, then the error is gone and the build is finally successful. I believe the reason is this, as mentioned by @svengau :If you still encountered the same error, try moving the original
.webp
and.svg
to another location.in my case, JIMP (used by Potrace) throws an error because it doens’t support webp. And Potrace doesn’t handle this error. I’ve created a bug report in Potrace project: https://github.com/tooolbox/node-potrace/issues/8
Hey guys, not sure if that will help, but I’m having same issue, when I’m querying images from Contentful. I’ve managed to narrow it down to this situation:
Looks pretty random. If you need more info let me know. Hope that helps.
I opened https://github.com/gatsbyjs/gatsby/pull/12927 PR that hopefully fixes that. Because of random nature of this errors I can’t be 100% sure on this