sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
77.47k stars 4.04k forks source link

Error on create multiple toasts with svelte-sonner #12273

Closed ariel-salgado closed 2 days ago

ariel-salgado commented 3 days ago

Describe the bug

Although this look like library a related problem, when upgrading svelte 5 from next.170 to next.171 broke the library. It seems very related to this.

Reproduction

The reproduction is very straight forward, when using the next.171 version if you click the button Toast to display a toast and wait until it goes away or dismiss, and click again it works fine, but if you spam the button it just creates one toast and then throws an error which you can see in the dev tools console.

This error doesnt exist in the next.170 version, and spamming the button creates a lot of toasts with no errors.

SvelteLab

I only installed svelte 5 and svelte sonner for the reproduction. So if you want to try it yourself it will work the same.

Logs

TypeError: Cannot read properties of null (reading 'start') at reconcile (chunk-...)...

System Info

SvelteLab

Severity

annoyance

raymonddaikon commented 3 days ago

I believe I'm having a similar issue where multiple dom updates in a single frame is throwing this error. I was able to mitigate this by manually requesting the next frame before every mutation but this breaks my logic as I'm doing multiple mutations inside a single yjs transaction.

trueadm commented 2 days ago

I think this is likely the same issue as https://github.com/sveltejs/svelte/issues/12280.

Rich-Harris commented 2 days ago

This is caused by a combination of hydration and the HMR wrapper, which is why it escaped our tests. Working on it. This is a simple repro, but the bug isn't visible in the preview REPL because there's no HMR/hydration there.