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-plugin-sharp] Error when using resize(base64: true) #19220

Closed
troyfendall opened this issue Nov 1, 2019 · 5 comments
Closed

[gatsby-plugin-sharp] Error when using resize(base64: true) #19220

troyfendall opened this issue Nov 1, 2019 · 5 comments
Labels
good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@troyfendall
Copy link

Description

When trying to use the resize method from gatsby-plugin-sharp with a parameter of base64: true I get the following error:

Errors:
  Cannot read property 'toFormatBase64' of undefined

  GraphQL request:4:7
  3 |     nodes {
  4 |       resize(width: 20, base64: true) {
    |       ^
  5 |         src

Steps to reproduce

Reproduction repository: https://github.com/troyfendall/gatsby-plugin-sharp-resize-bug

Use the following query:

    query IndexQuery {
        allImageSharp {
            nodes {
                resize(width: 20, base64: true) {
                    src
                }
            }
        }
    }

Expected result

What should happen?

A resized base64 image should be available for use and the build should succeed without error.

FWIW I traced through the gatsby-plugin-sharp code and found that defaulting args = {} on this line fixed the issue. Now, I don't know if the root issue is the lack of default or if there's an underlying issue that explains why the args are undefined there. Hopefully ya'll with better knowledge of the scheduler can decipher what's going on there.

Actual result

Errors:
  Cannot read property 'toFormatBase64' of undefined

  GraphQL request:4:7
  3 |     nodes {
  4 |       resize(width: 20, base64: true) {
    |       ^
  5 |         src

Environment

System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.7.0 - /usr/local/bin/yarn
    npm: 6.11.3 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/local/bin/python
  Browsers:
    Chrome: 78.0.3904.70
    Firefox: 69.0.1
    Safari: 13.0.3
  npmPackages:
    gatsby: 2.17.6 => 2.17.6
    gatsby-plugin-sharp: 2.2.36 => 2.2.36
    gatsby-source-filesystem: 2.1.35 => 2.1.35
    gatsby-transformer-sharp: 2.3.2 => 2.3.2
@LekoArts LekoArts added the type: bug An issue or pull request relating to a bug in Gatsby label Nov 5, 2019
@LekoArts
Copy link
Contributor

LekoArts commented Nov 5, 2019

Thanks for the issue! Tagging my colleagues cc @gatsbyjs/core

@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Nov 27, 2019
@github-actions
Copy link

github-actions bot commented Dec 7, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

@github-actions github-actions bot closed this as completed Dec 7, 2019
@wardpeet
Copy link
Contributor

@troyfendall Thanks for opening this bug! This is a simple one to fix.

The error is at this line:

async function generateBase64({ file, args, reporter }) {

The fix is to change this line into

async function generateBase64({ file, args = {}, reporter }) {

There might be something else going on but this at least fixes the error. More detective work is appreciated 🕵🕵️‍♀️.

@wardpeet wardpeet reopened this Dec 16, 2019
@wardpeet wardpeet added good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Dec 16, 2019
@sidharthachatterjee
Copy link
Contributor

This appears to have been fixed in #20158 thanks to @rileymiller

Let's close this issue. Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants