Skip to content

when ssr is true, img elements that throw 404 halt javascript from kicking in. #15412

@HighFunctioningSociopathSH

Description

Describe the bug

If you have img elements with wrong src attributes that result in a 404, you can notice that javascript doesn't kick in unless all the img elements are done throwing 404 and since browser request take time, this means your code can take a few seconds to run.

Reproduction

+page.svelte

<script lang="ts">
  console.log("hello");
</script>

<img src="some" />
<img src="arbitrary" />
<img src="src" />
<img src="values" />
<img src="that" />
<img src="result" />
<img src="in" />
<img src="404" />

The above code results in the following logs

GET http://localhost:5174/some 404 (Not Found) localhost/:335
GET http://localhost:5174/arbitrary 404 (Not Found) localhost/:335
GET http://localhost:5174/src 404 (Not Found) localhost/:335
GET http://localhost:5174/that 404 (Not Found) localhost/:335
GET http://localhost:5174/values 404 (Not Found) localhost/:335
GET http://localhost:5174/result 404 (Not Found) localhost/:335
GET http://localhost:5174/404 404 (Not Found) localhost/:335
GET http://localhost:5174/in 404 (Not Found) localhost/:335
[vite] connecting... client:495 
[vite] connected. client:614
hello +page.svelte:2 

But If you turn ssr off then the logs would be like

[vite] connecting... client:495 
[vite] connected. client:614
hello +page.svelte:2 
GET http://localhost:5174/some 404 (Not Found) localhost/:335
GET http://localhost:5174/arbitrary 404 (Not Found) localhost/:335
GET http://localhost:5174/src 404 (Not Found) localhost/:335
GET http://localhost:5174/that 404 (Not Found) localhost/:335
GET http://localhost:5174/values 404 (Not Found) localhost/:335
GET http://localhost:5174/result 404 (Not Found) localhost/:335
GET http://localhost:5174/404 404 (Not Found) localhost/:335
GET http://localhost:5174/in 404 (Not Found) localhost/:335

Logs

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-12650H
    Memory: 6.92 GB / 15.63 GB
  Binaries:
    Node: 23.7.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.1.0 - C:\Program Files\nodejs\npm.CMD
    bun: 1.1.3 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (129.0.2792.52)
    Internet Explorer: 11.0.22621.3527

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions