sveltejs / svelte

web development for the rest of us
https://svelte.dev
MIT License
79.84k stars 4.24k forks source link

Svelte 5: REPL sometimes doesn't show the code until F5 when opened in a background tab #12523

Open henrikvilhelmberglund opened 3 months ago

henrikvilhelmberglund commented 3 months ago

Describe the bug

No idea how or why this happens but I have a Svelte 5 REPL which seems to only load the code 50% of the time. This only happens when opening a REPL in a background tab.

Reproduction

  1. Open below in background tab by right clicking and Open link in new tab.
  2. Sometimes code isn't shown until F5.

REPL

Logs

No response

System Info

Latest Brave/Chromium/Edge

Severity

annoyance

Prinzhorn commented 3 months ago

Yep, I see this in Firefox all the time as well. In fact, I've opened your link in a new tab ten times and none showed code.

Edit: a quick look at this reveals that it's some issue with codemirror. The editor is in a bugged state. Typing in the editor (or trying to do so) will add more exception to the ones that exist on page load:

image

The first stack includes re.measure / requestMeasure, so my guess is that Svelte initially gives the editor a size of 0x0 or something because maybe ResizeObserver does not run in the background tab or whatever.