Code Monkey home page Code Monkey logo

Comments (10)

dummdidumm avatar dummdidumm commented on June 19, 2024

Please provide a proper minimum reproduction, the link has way too much side stuff going on.

from svelte.

nmathew98 avatar nmathew98 commented on June 19, 2024

alright will get a stackblitz going

from svelte.

nmathew98 avatar nmathew98 commented on June 19, 2024

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

adapting the stackblitz:
image

and the result is:

  • things break after depthOne: image

stackblitz: https://stackblitz.com/edit/svelte-bugs-10829-10828-10827?file=src%2FApp.svelte

from svelte.

7nik avatar 7nik commented on June 19, 2024

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.

7nik avatar 7nik commented on June 19, 2024

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.

nmathew98 avatar nmathew98 commented on June 19, 2024

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.

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 with L15 commented out, result updates so that children is not null and content updates to Depth 1
  • depthTwo runs with L34 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.

7nik avatar 7nik commented on June 19, 2024

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.

nmathew98 avatar nmathew98 commented on June 19, 2024

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.

image

from svelte.

7nik avatar 7nik commented on June 19, 2024

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.

nmathew98 avatar nmathew98 commented on June 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.