Comments (10)
Please provide a proper minimum reproduction, the link has way too much side stuff going on.
from svelte.
alright will get a stackblitz going
from svelte.
hey so it looks like its because the updates were done inside of async functions (both reactive assignments and store updates break)?
if I were to make the functions themselves sync but perform the updates within a promise I get the same result but if the functions are sync (just commenting out the call to sleep
but leaving depthOne
and depthTwo
marked as async
) then no issues
and the result is:
stackblitz: https://stackblitz.com/edit/svelte-bugs-10829-10828-10827?file=src%2FApp.svelte
from svelte.
The only error I see is that when both depthOne
and depthTwo
have sleep
the $data.children
is null
during rendering, and you get the very clear error message: Error: {#each} only works with iterable values.
.
Also, when both sleep periods are equal, depthTwo
can fire before depthOne
and crash with Uncaught (in promise) TypeError: $data.children is null
.
from svelte.
And I struggle to comprehend how I must see three different bugs (this, #10828 and #10829) with the same example.
Could you add reproduction steps, observed (wrong) result and expected result?
from svelte.
The only error I see is that when both
depthOne
anddepthTwo
havesleep
the$data.children
isnull
during rendering, and you get the very clear error message:Error: {#each} only works with iterable values.
. Also, when both sleep periods are equal,depthTwo
can fire beforedepthOne
and crash withUncaught (in promise) TypeError: $data.children is null
.
i mean is it expected behaviour that store updates and reactive assignments do not work when things are async?
also have updated the stackblitz so that the timeout for the second one is higher than the first, same issue
so in the stackblitz:
depthOne
runs withL15
commented out,result
updates so thatchildren
is not null andcontent
updates toDepth 1
depthTwo
runs withL34
not commented out,result
does not update
And I struggle to comprehend how I must see three different bugs (this, #10828 and #10829) with the same example.
Could you add reproduction steps, observed (wrong) result and expected result?
yea sorry, when it first came up in the test project and when I was creating the stackblitz i thought it was 3 different issues but it could just be because of async
from svelte.
Another error that I didn't mention because I thought it was obvious, especially after looking at the browser's console and seeing there ReferenceError: can't access lexical declaration 'sleep' before initialization
, - sleep
must be defined before depthOne
. I'm even not sure why this code works on the server.
from svelte.
if you're calling a function within a function, it doesn't matter the order of declarations. the declarations are loaded first and later when the fn is invoked it looks up the declaration and invokes.
from svelte.
your example isn't equal to the project's code. The correct example is
const x = () => { hello(); }; x(); const hello = () => console.log("hi!!");
The const
and let
variables even have special terminology for the state before initialization - Temporal Dead Zone.
I'm even not sure why this code works on the server.
It's not SvelteKit, so the code isn't running on the server.
So, just raise the definition of sleep
.
And for your information, if an error is thrown during the lifecycle (component initiation, rendering, processing the reactivity and so on), the entire Svelte app just stops because the app may have an impossible/out-of-sync state and it's unclear what to do in this case and still no API to resolve such cases.
from svelte.
that's my bad oops, sorry for being so haphazard, things are working now but I have no idea why the same is not happening in the application
will close the issues ive opened and dig into the issue more
from svelte.
Related Issues (20)
- Svelte 5: `<select>`/`<option>` elements get incorrect/inconsistent values when applying `undefined` with spread or reactive value HOT 3
- playground: console formatting isn't applied HOT 2
- Svelte 5: Setting the `loading` property for `img` in the `$effect` rune does not work HOT 2
- Svelte 5: Throw an error when importing svelte/internal/* HOT 3
- Binding scrollY to `svelte:window` causes implicit scrolling to the top of the page HOT 6
- Object literal may only specify known properties, and '"on:accept"' does not exist in type 'Omit<HTMLInputAttributes, keyof HTMLAttributes<any>> & HTMLAttributes<any>'. HOT 3
- Svelte 5 playground is freezing HOT 2
- Binding to store values not working correctly in Svelte 5 HOT 5
- Remove `indeterminate` from `HTMLInputAttributes` type HOT 1
- Default values for array-like props breaks rendering HOT 1
- Svelte 5: broken reactivity in legacy mode in rare case HOT 1
- Cannot find base config file "./.svelte-kit/tsconfig.json" [tsconfig.json] HOT 2
- Svelte 5: Binding `scrollY` to `svelte:window` does not update the initial value
- Svelte 5: `contenteditable="true"` with `bind:innerText` breaks the output of `{@render children()}` HOT 2
- Allow `textContent` / `innerHTML` / `innerText` binding without setting the `contenteditable` attribute HOT 4
- Transitions break when wrapped in component. HOT 2
- A slash in a style class breaks the class directive HOT 1
- svelte-ignore regression on Svelte 5 HOT 5
- ReferenceError: Request is not defined on launch HOT 1
- Svelte 5: add examples of mixing runes and store to documention HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte.