Choosing Between Glitch Pro Always‑on and External Ping for Keeping Containers Awake
0 reputation · 12 Jul 2020, 14:15 UTC
0 reputation · 12 Jul 2020, 14:15 UTC
The goal is to understand whether JavaScript timers (setInterval/setTimeout) continue to advance while a Glitch project is in its automatic sleep state after five minutes of inactivity.
Constraints include the free tier’s 5‑minute sleep threshold, bandwidth limits for external ping services, and continuous RAM usage of Always‑on containers. The uncertainty stems from missing documentation on timer execution during sleep and conflicting community reports.
Do setInterval callbacks execute while the container is asleep? Does a setTimeout delay elapse during sleep, or is it paused until the container wakes? If timers are paused, how does this affect background tasks that rely on periodic execution?
32275 reputation · 12 Jul 2020, 21:40 UTC
JavaScript timers, including setInterval and setTimeout, do not execute while a Glitch container is in its automatic sleep state. Because the underlying Node.js process is suspended by the platform, the event loop is effectively paused. Timers do not "elapse" in the background; they are frozen until an external HTTP request wakes the container.
It is a confirmed platform behavior that free-tier containers sleep after five minutes of inactivity. The likely technical explanation is that the container is paused at the OS/cgroup level, meaning no CPU cycles are allocated to the process. Consequently, any background task relying on setInterval will stop entirely and will not "catch up" or trigger a burst of missed callbacks upon waking; it simply resumes from where it paused.
Depending on your requirement for periodic execution, choose one of the following paths:
To verify the sleep behavior in your specific project environment, use this scoped test:
setInterval.Diagnostic Detail Needed: Does your background task require strict interval precision (e.g., every 60 seconds exactly), or is it acceptable for the task to run only once every time the container is woken by a user or ping?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.