Build finish successfully but get stuck and not exit
See original GitHub issueDescribe the bug
When running yarn build
the build finishes successfully but does not exit. This cause an issue with automating builds.
To Reproduce
I have boiled down the issue to having setInterval
in a script.
<script>
let time = 1;
setInterval(() => {
time += 1;
}, 1000);
</script>
{time}
A solution to this is of course to use onMount
<script>
import { onMount } from "svelte";
let time = 1;
onMount(() => {
setInterval(() => {
time += 1;
}, 1000);
})
</script>
{time}
Expected behavior
I’m not sure if this is expected behavior or not but, In Sapper
this did not happen, the first snippet of code run just fine.
Severity Not severe since there is a workaround but I think it maybe need to be documented.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Visual Studio hangs constantly during build - Stack Overflow
In Visual Studio, go to Tools / Options / Projects & Solutions / Build And Run, then check the MSBuild project build output...
Read more >Cancelling a build doesn't always work properly, leaving the ...
Starting a build of a solution, then choosing cancel from the build menu often causes VS to 'hang' indefinitely. The hang is not...
Read more >[Support Guide] Hung or stuck, but seemingly successful build
If even one thing gets stuck, the process won't terminate and we end up with a stuck build. Is it possible you are...
Read more >Build stuck on final "exit 0" - Jenkins Jira
After executing successfully the shell script the workers remain stuck for 10 minutes on the final "exit 0".
Read more >Troubleshoot Microsoft Defender for Endpoint onboarding ...
If the onboarding completed successfully but the devices are not ... Defender for Endpoint Policy registry key does not exist or the OMA...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this works with the new structure:
Interesting. I’m not entirely sure why it’s causing a hang in SvelteKit but not in Sapper. But, regardless, having a
setInterval
without aclearInterval
is a bad idea, because of memory leaks. And that’s especially a problem on the server, where every single time someone loads a page that contains that component, it creates anothersetInterval
, which then hangs around forever.I think the path forward here is not to make it not hang, but to do something to warn people that this is a bad thing to be doing. In SSR, there’s not really a reason to be creating an interval (or a timeout) at all, because it’s not going to fire until after the SSR’d HTML is rendered. I don’t know what’s an effective way to warn about this. Static analysis won’t really help. Do we override these globals with our own versions, and display a warning if we detect that one is being run during the synchronous period that the server-side rendering is happening? I’m not sure.