Weird problem in latest gatsby-plugin-image - root.current is null #35656
-
I'm seeing a really weird issue in the latest gatsby-plugin-image (2.14) For most images all is fine, but occasionally I'm seeing an error in the GatsbyImageHydrator. For some of the images I've done some tweaks locally and the page appears to work ok if I check that root.current is actually set as in line 163 ( )However I've really struggled to create a minimal reproduction. I've got a small project that loads some images, even loads a few hundred images and still works correctly. |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 8 replies
-
I did a little digging today in attempts at isolating props/usage behaviour, but to no avail. I can't really understand how root.current could be null at any time, since it doesn't seem to have any conditional rendering. That leads me to believe it is caused by parent components unmounting GatsbyImage temporarily while the erroring Promise.then resolves. That would also explain why it is not a widespread reported problem, since that would be pretty rare. Unfortunately I could not prove this even though I attempted various stuff, like doing React.memo on some parents, removing some useEffects etc. To add some context for our environment which could be relevant, we are using sanity(through gatsby-source-sanity 7.4.2) and styled-components 5.3.3. I will stay on the last known good version 2.13 for a month or two in hopes that this magically gets fixed, but if not I will dedicate the time required to fix it. |
Beta Was this translation helpful? Give feedback.
-
Downgrading to 2.13.0 solved the issue for us. We had a tangential issue which was bad gatsbyImageData queries. They produced similar errors but were unrelated. |
Beta Was this translation helpful? Give feedback.
-
Same issue here (2.15.0), will be downgrading for now On a new Gatsby install with two images fetched with the WordPress source plugin.
|
Beta Was this translation helpful? Give feedback.
-
Is there any reproduction available? Or is it randomly happening? I think I know where the problem lies but want to make sure I can test it |
Beta Was this translation helpful? Give feedback.
-
A repository has been created where the phenomenon can be confirmed. This repository uses react-masonry-css. |
Beta Was this translation helpful? Give feedback.
-
I do not have react-masonry-css and still have the error. Good job with the
reproduction repo. Must be a shared pattern in how that lib and many others
use gatsby img
man. 6. jun. 2022 kl. 00:09 skrev stldo ***@***.***>:
… react-masonry-css is causing this issue here too.
—
Reply to this email directly, view it on GitHub
<#35656 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKOKWIK3A7AYIQIHMJDJDTVNUQPXANCNFSM5V5CVXXQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
We're using tailwindcss. Some of our projects are working ok, others aren't so I haven't been able to find a pattern to reproduce it yet. |
Beta Was this translation helpful? Give feedback.
-
Perhaps there's a bug where the image component is removed by a parent but there's some code in the component which still runs. |
Beta Was this translation helpful? Give feedback.
-
I've made a basic reproduction here I can't say I understand what's actually going on, but it's as Kyle says, the bug happens if the image is removed before it's finished loading. It's very easy to recreate - just render an image and remove it after 1ms |
Beta Was this translation helpful? Give feedback.
-
This will be fixed in this PR #35878 |
Beta Was this translation helpful? Give feedback.
This will be fixed in this PR #35878