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

Prevent possible endless loop with image fallback #444

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

jean-the-coder
Copy link
Contributor

Description

So I noticed that in the Storybook upload off of main that the medical sources card component is erroring out and it isn't able to generate snapshots. When I click into it on the website it seems like there are two problems:

  1. The assets aren't getting added to the storybook upload causing the fallback image not to be found.
  2. The image fallback directive is trapped in an endless loop looking for the fallback image.

I found some docs saying that serving static assets via Storybook configuration is recommended so I've tried adding that configuration. I'm not sure if it will work, or if this is what is causing the component error making the build fail, but I figured it was worth a shot.

As for the second issue, I've updated the image fallback code so that it shouldn't endlessly loop in the case that even the fallback image fails. Basically it just checks to see if the failed image was the fallback image and if it was, return rather than resetting src which triggers another attempt and error and so on.

Changes

  • add config to storybook for serving static assets
  • only attempt to load fallback image if we haven't already tried to load it

@AnalogJ
Copy link
Member

AnalogJ commented Mar 6, 2024

wow, this is a 🤦 moment for me. Great catch.

@AnalogJ AnalogJ merged commit d025251 into fastenhealth:main Mar 6, 2024
4 checks passed
@jean-the-coder jean-the-coder deleted the image-fallback-loop branch March 6, 2024 19:32
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.

None yet

2 participants