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

fix(gatsby-plugin-sharp): error if we can't determine dimensions for image #23156

Merged
merged 2 commits into from
Apr 16, 2020

Conversation

TylerBarnes
Copy link
Contributor

This adds an error when dimensions for an image can't be determined. This happens when a file is corrupt. Previously the only error we got was TypeError: Cannot read property 'width' of null. I explored using another image dimensions package that gives us more meaning errors but it was giving other unrelated errors and seems like a risky change. Since the current package returns null if it can't find dimensions, I just error on null dimensions here and provide a generic message.

@TylerBarnes TylerBarnes requested a review from a team as a code owner April 16, 2020 00:01
@TylerBarnes
Copy link
Contributor Author

Prettier 2 added a bunch of extra changes on commit via husky. I can't make it not do that without downgrading prettier or removing husky, so I assume this is fine.

@vladar vladar changed the title error if we can't determine dimensions for image fix(gatsby-plugin-sharp): error if we can't determine dimensions for image Apr 16, 2020
@vladar
Copy link
Contributor

vladar commented Apr 16, 2020

@TylerBarnes Looks like you have old Prettier (which uses new .prettierrc). Prettier 2.0 shouldn't add those changes (and that's why linting fails now). Run yarn and try again - it should help.

pvdz
pvdz previously requested changes Apr 16, 2020
Copy link
Contributor

@pvdz pvdz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't merge Prettier related issues when it's due to Prettier 1 runtime on a Prettier 2 config.

@pvdz
Copy link
Contributor

pvdz commented Apr 16, 2020

Turns out you can run /oss format 23156 if you run into this issue again, to fix the Prettier 1 vs 2 problems. As a workaround at least.

@pvdz
Copy link
Contributor

pvdz commented Apr 16, 2020

(Consider my request for changes removed. Github won't let me, other than to accept it, but that's not what we want either, so meh. Ignore me in this PR :) )

@TylerBarnes
Copy link
Contributor Author

Thanks @pvdz , I thought it was from our new config or something. Good to know I just need to use v2 instead

@TylerBarnes TylerBarnes dismissed pvdz’s stale review April 16, 2020 20:58

fixed by /oss format bot

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!!!

@TylerBarnes TylerBarnes merged commit e11c970 into gatsbyjs:master Apr 16, 2020
@TylerBarnes TylerBarnes deleted the feat/report-corrupt-images branch April 16, 2020 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants