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 breaks in production after reload #27732

Closed
AlanJereb opened this issue Oct 30, 2020 · 6 comments
Closed

Gatsby-image breaks in production after reload #27732

AlanJereb opened this issue Oct 30, 2020 · 6 comments
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@AlanJereb
Copy link

AlanJereb commented Oct 30, 2020

Description

Image component works correctly in development. In production, however, it works correctly if we visit the blog post through website navigation, but as soon as we reload or visit the link to the blog post directly, the image breaks.

Steps to reproduce

  1. Visit: https://www.alanjereb.com/blog
  2. Click on the blogpost: "Ending with a surprise"
    slika
  3. See subheading: The Britten empire (loads as intended)
    slika
  4. Reload the page or visit the blogpost link directly (first image breaks)
    slika

repo: https://github.com/AlanJereb/alanjereb.com_Gatsby
Image generation code:

<div className={blogStyles.imageContainer} key={index}>
                                <div>
                                    <div onClick={() => openLightbox(id)}>
                                        <Img fluid={localUrlEdge.node.localFile.childImageSharp.fluid} alt={alt} title={alt} imgStyle={{ objectFit: 'contain' }} style={{ maxHeight: "417px" }} />
                                    </div>
                                    <div className={blogStyles.lightbox} id={id} onClick={() => openLightbox(id)}>
                                        <Img fluid={localUrlEdge.node.localFile.childImageSharp.fluid} alt={alt} title={alt} imgStyle={{ objectFit: 'contain' }} style={{ maxWidth: "1140px" }} />
                                        <h4>{alt}</h4>
                                    </div>
                                </div>
                                <p>{alt}</p>
                            </div>

Expected result

It should work as it does in development.

Environment

System:
    OS: Windows 10 10.0.19041
    CPU: (16) x64 Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz
  Binaries:
    Node: 12.18.4 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.423.0)
  npmPackages:
    gatsby: ^2.24.67 => 2.24.86
    gatsby-image: ^2.4.21 => 2.4.21
    gatsby-plugin-react-helmet: ^3.3.14 => 3.3.14
    gatsby-plugin-sass: ^2.3.16 => 2.3.21
    gatsby-plugin-sharp: ^2.6.42 => 2.6.43
    gatsby-remark-images: ^3.3.34 => 3.3.39
    gatsby-remark-images-contentful: ^2.3.19 => 2.3.19
    gatsby-remark-relative-images: ^2.0.2 => 2.0.2
    gatsby-source-contentful: ^2.3.55 => 2.3.56
    gatsby-source-filesystem: ^2.3.34 => 2.3.36
    gatsby-transformer-remark: ^2.8.38 => 2.8.46
    gatsby-transformer-sharp: ^2.5.18 => 2.5.20
  npmGlobalPackages:
    gatsby-cli: 2.12.106
@AlanJereb AlanJereb added the type: bug An issue or pull request relating to a bug in Gatsby label Oct 30, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 30, 2020
@LekoArts LekoArts added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Nov 2, 2020
@LekoArts
Copy link
Contributor

LekoArts commented Nov 2, 2020

Hi!

Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it. This way we don't need to access your Contentful space and in the process of making it you can see if you whole modifiedResponse logic is the culprit, e.g. wrong index. Because displaying images in a row works fine, it must be something specific to your code/project.

If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.

Thanks for using Gatsby! 💜

@LekoArts LekoArts closed this as completed Nov 2, 2020
@LekoArts LekoArts reopened this Nov 2, 2020
@LekoArts
Copy link
Contributor

Hi!

Since we didn't receive an answer for 7 business days or more about the ask of a reproduction I'm going to close this now, as we can't do much to help without a reproduction. If you are able to create a minimal reproduction for this then please do answer here or reopen the issue. Thanks!

@emilkarl
Copy link

I have the same problem, did you find a solution to it @AlanJereb?

@AlanJereb
Copy link
Author

I have the same problem, did you find a solution to it @AlanJereb?

Sadly no. If you find it, please ping me.

@emilkarl
Copy link

Tried rewriting how we did this but still the same problem. On page reload in production the Gastby image is closing its div without adding and padding or anything too it. We are using twin.macro if that could have any impact? 🤷‍♂️

Code after reload

<div class="wallet___StyledDiv-wbrzp-8 hMlsJK">
  <div></div>
  <img
    aria-hidden="true"
    src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAfCAYAAADnTu3OAAAACXBIWXMAABYlAAAWJQFJUiTwAAAFqUlEQVRIx+XVe2xTVRwH8NuxIVv3au/ds91wbC2CDtjbsUd72z2YxEVIRIWo0QBDocDYCwZOoyORuRn2psGEhyJgosJgCTFAMiNVhiA4eXRb2z3bvbrubsPhbvc7/roxtgl/+IcmJp7kk++59/Z+c25P00tR//khFAofchcIhR7I3QnTYd7DfCJXV6ETTfvOS05WTvaEhy+nDpR8+s8sSp2SPnMgk8vmI1oul4XI5fJlmImYGTK5PBPzRQe8/piwsLDMpUufzVi//nU3R8/0SikXl6d8XFwWpKAcFxfXY+gmgvnz3cgU4RM5O09dC14YUuDocXJynseqUijK0zOK8faOVorFcdvEdHwtTcf/QNMrbTSdOEEziTztk2SnfZR2xldp9/VT2/39UuwSSbpdJn/5ga9fLBGJRNNfnFNkZDRFlRw4zJSUfMZ+9GGVpvijGu3+4lrd/v21XFnpUVJaegRKy45CWdkxdBzKSo9DVeUpyN5ZCs8seYOXBimJWCw68KgwKoai9M0m5trNFrbp1k1Ni16vbTcadR0mE2fu6iSdbW2A80dMBgP09XTDV6fqIEz2Ki+RKrBQXDKn0NBqZAwGE9ve3q7paO/Q3v7ttu7GjV+469dvEP09PZhMbWA0mMBoNE1mX28PnD5dj4WvPVYY5SjkhoaZ7i4zizdojAajtqO9U2cx93AWs4X09w3AoHUQrANTurvNMHp/GOrqLsHixRv4oMlHnl0Yiys0G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ijrAVmOHLI+SR0bGytFUZ3v/Oiz4ldRWVmuaQQaWlZwhwLsBzKF2gUqcJWFUqShEoWLUgWaESJCWzgsQkpSAhUSFYmZAsiE9Impw77i/c9wH1Pxx/AhlLsGPY6goqAAAAAElFTkSuQmCC"
    alt=""
    style="
      position: absolute;
      top: 0px;
      left: 0px;
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center center;
      opacity: 0;
      transition-delay: 500ms;
    "
  /><picture
    ><source
      srcset="
        /static/f2c408bf6eab9886c192a09009549b84/6d161/macos.png 150w,
        /static/f2c408bf6eab9886c192a09009549b84/630fb/macos.png 300w,
        /static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png 600w,
        /static/f2c408bf6eab9886c192a09009549b84/ead32/macos.png 876w
      "
      sizes="(max-width: 600px) 100vw, 600px" />
    <img
      sizes="(max-width: 600px) 100vw, 600px"
      srcset="
        /static/f2c408bf6eab9886c192a09009549b84/6d161/macos.png 150w,
        /static/f2c408bf6eab9886c192a09009549b84/630fb/macos.png 300w,
        /static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png 600w,
        /static/f2c408bf6eab9886c192a09009549b84/ead32/macos.png 876w
      "
      src="/static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png"
      alt=""
      loading="lazy"
      style="
        position: absolute;
        top: 0px;
        left: 0px;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center center;
        opacity: 1;
        transition: opacity 500ms ease 0s;
      " /></picture

  ><noscript
    ><picture
      ><source
        srcset="
          /static/f2c408bf6eab9886c192a09009549b84/6d161/macos.png 150w,
          /static/f2c408bf6eab9886c192a09009549b84/630fb/macos.png 300w,
          /static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png 600w,
          /static/f2c408bf6eab9886c192a09009549b84/ead32/macos.png 876w
        "
        sizes="(max-width: 600px) 100vw, 600px" />
      <img
        loading="lazy"
        sizes="(max-width: 600px) 100vw, 600px"
        srcset="
          /static/f2c408bf6eab9886c192a09009549b84/6d161/macos.png 150w,
          /static/f2c408bf6eab9886c192a09009549b84/630fb/macos.png 300w,
          /static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png 600w,
          /static/f2c408bf6eab9886c192a09009549b84/ead32/macos.png 876w
        "
        src="/static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png"
        alt=""
        style="
          position: absolute;
          top: 0;
          left: 0;
          opacity: 1;
          width: 100%;
          height: 100%;
          object-fit: cover;
          object-position: center;
        " /></picture
  ></noscript>
</div>

Code when entering by clicking a link

<div
  class="wallet___StyledImg-wbrzp-7 kQBYtB gatsby-image-wrapper"
  style="position: relative; overflow: hidden;"
>
  <div aria-hidden="true" style="width: 100%; padding-bottom: 157.333%;"></div>
  <img
    aria-hidden="true"
    src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAfCAYAAADnTu3OAAAACXBIWXMAABYlAAAWJQFJUiTwAAAFqUlEQVRIx+XVe2xTVRwH8NuxIVv3au/ds91wbC2CDtjbsUd72z2YxEVIRIWo0QBDocDYCwZOoyORuRn2psGEhyJgosJgCTFAMiNVhiA4eXRb2z3bvbrubsPhbvc7/roxtgl/+IcmJp7kk++59/Z+c25P00tR//khFAofchcIhR7I3QnTYd7DfCJXV6ETTfvOS05WTvaEhy+nDpR8+s8sSp2SPnMgk8vmI1oul4XI5fJlmImYGTK5PBPzRQe8/piwsLDMpUufzVi//nU3R8/0SikXl6d8XFwWpKAcFxfXY+gmgvnz3cgU4RM5O09dC14YUuDocXJynseqUijK0zOK8faOVorFcdvEdHwtTcf/QNMrbTSdOEEziTztk2SnfZR2xldp9/VT2/39UuwSSbpdJn/5ga9fLBGJRNNfnFNkZDRFlRw4zJSUfMZ+9GGVpvijGu3+4lrd/v21XFnpUVJaegRKy45CWdkxdBzKSo9DVeUpyN5ZCs8seYOXBimJWCw68KgwKoai9M0m5trNFrbp1k1Ni16vbTcadR0mE2fu6iSdbW2A80dMBgP09XTDV6fqIEz2Ki+RKrBQXDKn0NBqZA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5+xc7snEuFe4vMe997f3RP4b7hgt2FI3n5e0Z25RaM7NyVO6LZkT3y7rbtI1nvbB3euClrNGvLVvNbb29qWrN2XVNufmExpVConJKSlK7IS6FQ+6hUqZLY2PhF+M8RFhkVGxoZGTMpIjI6NCJijrAVmOHLI+SR0bGytFUZ3v/Oiz4ldRWVmuaQQaWlZwhwLsBzKF2gUqcJWFUqShEoWLUgWaESJCWzgsQkpSAhUSFYmZAsiE9Impw77i/c9wH1Pxx/AhlLsGPY6goqAAAAAElFTkSuQmCC"
    alt=""
    style="
      position: absolute;
      top: 0px;
      left: 0px;
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center center;
      opacity: 0;
    "
  /><picture
    ><source
      srcset="
        /static/f2c408bf6eab9886c192a09009549b84/6d161/macos.png 150w,
        /static/f2c408bf6eab9886c192a09009549b84/630fb/macos.png 300w,
        /static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png 600w,
        /static/f2c408bf6eab9886c192a09009549b84/ead32/macos.png 876w
      "
      sizes="(max-width: 600px) 100vw, 600px" />
    <img
      sizes="(max-width: 600px) 100vw, 600px"
      srcset="
        /static/f2c408bf6eab9886c192a09009549b84/6d161/macos.png 150w,
        /static/f2c408bf6eab9886c192a09009549b84/630fb/macos.png 300w,
        /static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png 600w,
        /static/f2c408bf6eab9886c192a09009549b84/ead32/macos.png 876w
      "
      src="/static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png"
      alt=""
      loading="lazy"
      style="
        position: absolute;
        top: 0px;
        left: 0px;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center center;
        opacity: 1;
        transition: none 0s ease 0s;
      " /></picture

  ><noscript
    ><picture
      ><source
        srcset="
          /static/f2c408bf6eab9886c192a09009549b84/6d161/macos.png 150w,
          /static/f2c408bf6eab9886c192a09009549b84/630fb/macos.png 300w,
          /static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png 600w,
          /static/f2c408bf6eab9886c192a09009549b84/ead32/macos.png 876w
        "
        sizes="(max-width: 600px) 100vw, 600px" />
      <img
        loading="lazy"
        sizes="(max-width: 600px) 100vw, 600px"
        srcset="
          /static/f2c408bf6eab9886c192a09009549b84/6d161/macos.png 150w,
          /static/f2c408bf6eab9886c192a09009549b84/630fb/macos.png 300w,
          /static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png 600w,
          /static/f2c408bf6eab9886c192a09009549b84/ead32/macos.png 876w
        "
        src="/static/f2c408bf6eab9886c192a09009549b84/2a4de/macos.png"
        alt=""
        style="
          position: absolute;
          top: 0;
          left: 0;
          opacity: 1;
          width: 100%;
          height: 100%;
          object-fit: cover;
          object-position: center;
        " /></picture
  ></noscript>
</div>

@emilkarl
Copy link

@AlanJereb solved it by removing my classes from the image and putting them on a wrapper div instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

3 participants