Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop error in REPL when using generators #4698

Closed
BillyLevin opened this issue Apr 20, 2020 · 3 comments · Fixed by #4716
Closed

Infinite loop error in REPL when using generators #4698

BillyLevin opened this issue Apr 20, 2020 · 3 comments · Fixed by #4716

Comments

@BillyLevin
Copy link
Contributor

Describe the bug
Using a generator on the Svelte REPL gives an error: "Infinite loop detected". Nothing seems to freeze and the code works fine when I run it in my own repo. I'm not sure if the error message is incorrect or if Svelte does something with generators/iterators that I'm not aware of.

Logs
This is the log from the REPL linked in the next section
image

To Reproduce
Create a generator and call the next() method on it inside a button onclick function. Click the button a couple of times and you'll get the error message. Here is a basic example where I'm updating some simple state:

https://svelte.dev/repl/6d6346405cbd4267b82c53aa0218f536?version=3.20.1

Expected behavior
There shouldn't be an infinite loop error

Information about your Svelte project:

  • Browser: Chrome 80

  • OS: Windows 10

  • Svelte version: 3.20.1 (current REPL version)

Severity
How severe an issue is this bug to you? Is this annoying, blocking some users, blocking an upgrade or blocking your usage of Svelte entirely?

Not severe at all as my code seems to work outside of the REPL. I'd mostly like to make sure I'm not doing something wrong :)

Thanks!

@pushkine
Copy link
Contributor

pushkine commented Apr 23, 2020

the loopguard is timeout based so it's not compatible with generators
I can't think of a way to fix this other than counting iterations

@BillyLevin
Copy link
Contributor Author

Hey, thanks for the response!

After digging into ESTree a little, I think I found a way to opt out of loop_protect for generators. I'll submit a PR tomorrow :)

@Conduitry
Copy link
Member

This has been fixed in 3.22.0 - https://svelte.dev/repl/6d6346405cbd4267b82c53aa0218f536?version=3.22.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants