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

(life cycle: onDestroy) tutorial does not clear intervals when recompiling. #146

Closed
nasheomirro opened this issue Mar 20, 2021 · 3 comments
Labels
bug Something isn't working REPL

Comments

@nasheomirro
Copy link

Description
typing out setInterval function calls will result in the console being flooded with error messages, largely because there is no milliseconds passed yet and the variables being used still haven't been fully typed. The setInterval function call it self is valid so the compiler will compile and re render the result.

Logs
Error: s is not defined
Error: se is not defined
Error: sec is not defined
Error: second is not defined
Error sec is not defined
...

To Reproduce
On the editor, type a setInterval call slowly and must have an ending parentheses i.e setInterval().
NOTE: type the setInterval call inside the App.svelte script tag. I'm sure this is also the case with other tutorials using
setInterval() inside the script tag.

You will notice that if it compiles while you haven't finished typing it all out, the console is being flooded.
The problem will persist even when recompiling the code.

Expected behavior
The console shouldn't be printing any more errors when the answer is working.

Severity
VERY MINOR - just a problem with logging errors in the tutorial, people will get confused if they encounter this though.

@Conduitry Conduitry transferred this issue from sveltejs/svelte Mar 24, 2021
@Conduitry
Copy link
Member

Transferring this to the REPL repository, although I'm not sure what we could reasonably do to resolve this. Maybe monkeypatch/inject our own copies of setTimeout/setInterval that internally note somewhere the timeout/interval id so that we can manually destroy them when recompiling?

@Conduitry
Copy link
Member

sveltejs/svelte#7196 brought up the same sort of issue with requestAnimationFrame, and I'm not sure how to best handle that, either.

@benmccann
Copy link
Member

closing since the site has been rewritten. please file at https://github.com/sveltejs/svelte.dev/issues/new if the issue persists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working REPL
Projects
None yet
Development

No branches or pull requests

4 participants