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

Gatsby image crashes with unhelpful message if not passed any parameters #25370

Closed
ehrencrona opened this issue Jun 28, 2020 · 0 comments · Fixed by #25371
Closed

Gatsby image crashes with unhelpful message if not passed any parameters #25370

ehrencrona opened this issue Jun 28, 2020 · 0 comments · Fixed by #25371
Assignees
Labels
topic: media Related to gatsby-plugin-image, or general image/media processing topics type: bug An issue or pull request relating to a bug in Gatsby

Comments

@ehrencrona
Copy link
Contributor

Description

Including a Gatsby image on a page without any parameters, like so <Img />, crashes the page at runtime with the error message TypeError: Cannot read property '0' of undefined.

I came across this in a Stackoverflow question

Steps to reproduce

Create a new site using gatsby new site, change <Img fluid={data.placeholderImage.childImageSharp.fluid} /> in src/components/image.js to <Img/>

Expected result

I'd expect the image not to render and possibly an error to be printed on the console.

Actual result

Page crashes as per above.

Environment

  System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (8) x64 Intel(R) Xeon(R) CPU @ 2.30GHz
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 14.4.0 - /usr/bin/node
    Yarn: 1.22.4 - /usr/bin/yarn
    npm: 6.14.5 - /usr/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python

(Gatsby version corresponds to master built from source)

@ehrencrona ehrencrona added the type: bug An issue or pull request relating to a bug in Gatsby label Jun 28, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 28, 2020
@ehrencrona ehrencrona changed the title Gatsby image crashes with unhelpful message if not passed any parameters. Gatsby image crashes with unhelpful message if not passed any parameters Jun 28, 2020
@blainekasten blainekasten added topic: media Related to gatsby-plugin-image, or general image/media processing topics and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: media Related to gatsby-plugin-image, or general image/media processing topics type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants