question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[gatsby-plugin-sharp] reporterError swallows detailed error infos

See original GitHub issue

Description

In case my cached images are trashed (not sure why this is happening), I do get unhelpful error messages.

error [object Object] Input file contains unsupported image format


  Error: Input file contains unsupported image format

Steps to reproduce

Reproduction repo https://github.com/rburgst/bug-repro-28474

In https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-sharp/src/index.js#L439

  try {
    metadata = await sharp(file.absolutePath).metadata();
  } catch (err) {
    reportError(`Failed to retrieve metadata from image ${file.absolutePath}`, err, reporter);
    return null;
  }

I get the following error

message = "Failed to retrieve metadata from image /my-gatsby-project/.cache/caches/gatsby-source-wordpress-experimental/d41d8cd98f00b204e9800998ecf8427e/ISM_MoWo2018_Plakat_1.jpg"
err: Error = {
  stack: "Error: Input file contains unsupported image format",
  message: "Input file contains unsupported image format"
}

Then the call to reportError (in https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-sharp/src/report-error.js) in combination to the structured error reporting will strip all useful info from the error message.

You can produce this by just touching a cached image file so that it has 0 bytes.

Expected result

Expected the message to contain the reference to the broken file.

Actual result

Instead I get this useless error log:

error [object Object] Input file contains unsupported image format


  Error: Input file contains unsupported image format

Environment

  System:
    OS: macOS 10.15.7
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.18.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.0.14 - /usr/local/bin/npm
  Languages:
    Python: 2.7.17 - /usr/local/bin/python
  Browsers:
    Chrome: 87.0.4280.88
    Firefox: 83.0
    Safari: 14.0.1
  npmPackages:
    gatsby: ^2.28.0 => 2.28.0 
    gatsby-background-image: ^1.3.1 => 1.3.1 
    gatsby-image: ^2.7.0 => 2.7.0 
    gatsby-plugin-google-gtag: ^2.4.0 => 2.4.0 
    gatsby-plugin-graphql-codegen: ^2.7.1 => 2.7.1 
    gatsby-plugin-intl: ^0.3.3 => 0.3.3 
    gatsby-plugin-manifest: ^2.8.0 => 2.8.0 
    gatsby-plugin-offline: ^3.6.0 => 3.6.0 
    gatsby-plugin-react-helmet: ^3.6.0 => 3.6.0 
    gatsby-plugin-sass: ^2.7.0 => 2.7.0 
    gatsby-plugin-sharp: ^2.10.0 => 2.10.0 
    gatsby-plugin-sitemap: ^2.8.0 => 2.8.0 
    gatsby-plugin-typescript-checker: ^1.1.1 => 1.1.1 
    gatsby-plugin-use-query-params: ^1.0.1 => 1.0.1 
    gatsby-react-router-scroll: ^3.3.0 => 3.3.0 
    gatsby-source-apiserver: ^2.1.7 => 2.1.7 
    gatsby-source-filesystem: ^2.7.0 => 2.7.0 
    gatsby-source-mysql: ^2.2.3 => 2.2.3 
    gatsby-source-wordpress-experimental: ^4.0.0 => 4.0.0 
    gatsby-source-wordpress-menus: ^1.1.3 => 1.1.4 
    gatsby-transformer-sharp: ^2.8.0 => 2.8.0 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AleksandrHovhannisyancommented, Dec 14, 2020

Getting this as well. The error message is not very helpful.

0reactions
KyleAMathewscommented, Dec 17, 2020

Thanks for the reproduction @rburgst! With the work in https://github.com/gatsbyjs/gatsby/pull/28614 I think we can close this. I upgraded to the latest versions of the packages in your repro and now get the following error:

Screen Shot 2020-12-16 at 8 59 36 PM

Let us know if this pops up again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

gatsby-plugin-sharp
Exposes several image processing functions built on the Sharp image processing library. This is a low-level helper plugin generally used by other Gatsby...
Read more >
Untitled
Critical process error windows 10, Berthon boatyard romsey. Atle pettersen tattoo, Camp pupukea map, Market 3d media, Pa4 reddit, Phong van tap 18...
Read more >
ZXB - River Thames Conditions - Environment Agency - GOV.UK
Maillot garmin sharp 2014, Parker street alena, Shark tank all 5 sharks invest, ... Miptv daily news, Tamanho folha a4 em cm, System...
Read more >
Untitled
... time time in milliseconds Call the reporter that you're trying to time, ... ,fail,increasingly,investigation,liked,false,reader,tickets,error,watched ...
Read more >
Untitled
Hack de legend online con cheat engine, Shows like full house on netflix, ... Mount hood train station, 075 210 xerox error, Nba...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found