From e11c970b3066f6579962dd26410af2b71f16058f Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Thu, 16 Apr 2020 14:34:53 -0700 Subject: [PATCH] =?UTF-8?q?fix(gatsby-plugin-sharp):=20error=20if=20we=20c?= =?UTF-8?q?an't=20determine=20dimensio=E2=80=A6=20(#23156)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * error if we can't determine dimensions for image * chore: format Co-authored-by: gatsbybot --- packages/gatsby-plugin-sharp/src/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/gatsby-plugin-sharp/src/index.js b/packages/gatsby-plugin-sharp/src/index.js index f59a5993c2082..37d8275035d67 100644 --- a/packages/gatsby-plugin-sharp/src/index.js +++ b/packages/gatsby-plugin-sharp/src/index.js @@ -30,6 +30,14 @@ const getImageSize = file => { const dimensions = imageSize.sync( toArray(fs.readFileSync(file.absolutePath)) ) + + if (!dimensions) { + reportError( + `gatsby-plugin-sharp couldn't determine dimensions for file:\n${file.absolutePath}\nThis file is unusable and is most likely corrupt.`, + `` + ) + } + imageSizeCache.set(file.internal.contentDigest, dimensions) return dimensions }