Svelte: Infinite loop with {#async}

Created on 23 Jul 2019  路  5Comments  路  Source: sveltejs/svelte

Describe the bug

{#async} block causes an infinite loop, like so:

  1. Call a function func in {#await func()}
  2. Inside function func, assign to a variable outside of the function's scope
  3. Use that variable inside the {:then} block
  4. func() will now be called in an infinite loop.

To Reproduce

  1. Go to: https://svelte.dev/repl/1db5d06a6a214abda7373c1fc18f376a?version=3.6.7
  2. Open your console.

Expected behavior

  • Async function to be called once

Severity
Well our users don't like their browsers in infinite loops.

Most helpful comment

It would be great to have some kind of counter running behind the scenes, in development mode. Some way of detecting that "hey were probably in an infinite loop" and then stop with an error that gives a clue where.

Over in Angular world there is something along these lines. It produces the error "expression changed after it has been checked". It is very helpful for noticing certain kinds of problematic code early in development.

All 5 comments

It would be great to have some kind of counter running behind the scenes, in development mode. Some way of detecting that "hey were probably in an infinite loop" and then stop with an error that gives a clue where.

Over in Angular world there is something along these lines. It produces the error "expression changed after it has been checked". It is very helpful for noticing certain kinds of problematic code early in development.

<Options options={res.options}/>

This solves your issue

This solves your issue

@ms747 Yes, but it doesn't remove the bug in Svelte.

@arggh My bad, Yes there is a bug.

This appears to have been fixed in 3.9.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sskyy picture sskyy  路  3Comments

Rich-Harris picture Rich-Harris  路  3Comments

mmjmanders picture mmjmanders  路  3Comments

matt3224 picture matt3224  路  3Comments

rob-balfre picture rob-balfre  路  3Comments