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

[Bug?]: img onError not being triggered when using SSR #1122

Closed
2 tasks done
JetpackDuba opened this issue Nov 14, 2023 · 2 comments
Closed
2 tasks done

[Bug?]: img onError not being triggered when using SSR #1122

JetpackDuba opened this issue Nov 14, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@JetpackDuba
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

When an image fails loading, onError is not triggered when SSR is enabled in vite.config.ts. I've attached a minimal reproducer of the issue:

import Logo from "~/assets/app_logo.svg"
import { Show, createSignal } from "solid-js"

export default function Home() {
  const [showAlternativeImage, setShowAlternativeImage] = createSignal(false)

  return <div class="w-60 h-[360px]">
    <Show
      when={!showAlternativeImage()}
      fallback={
        <div class="bg-slate-700 w-full h-full">
          <img src={Logo} class="w-full h-full" />
        </div>
      }
    >
      <img
        class="w-full h-full"
        src="" // use any invalid url
        onError={(error) => {
          console.log(error)
          setShowAlternativeImage(true)
        }}
      />
    </Show>
  </div>
}

If I open the page when SSR enabled, it will show the typical image load failed but onError would not have been triggered.

Expected behavior 🤔

OnError should be triggered even if SSR is enabled.

Steps to reproduce 🕹

Steps:

  1. Create an app with the sample code in the main route and SSR enabled.
  2. Open the page and check alternative image not showing up nor logs about the error.
  3. Disable SSR
  4. Ctrl + R in the page to refresh.

Context 🔦

I am trying to load images from dynamic paths, but if the image has failed loading it should show a default image.

Your environment 🌎

No response

@JetpackDuba JetpackDuba added the bug Something isn't working label Nov 14, 2023
@tkirda
Copy link

tkirda commented Nov 21, 2023

@JetpackDuba This issue is invalid. Images do not load during server-side rendering, so it's impossible to determine if image URL is valid.

@ryansolid
Copy link
Member

In setting up for SolidStart's next Beta Phase built on Nitro and Vinxi we are closing all PRs/Issues that will not be merged due to the system changing. If you feel your issue was closed by mistake. Feel free to re-open it after updating/testing against 0.4.x release. Thank you for your patience.

See #1139 for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants