I set quite a few server-side timeouts with setTimeout and setInterval for each connected user that can last for 10-30 seconds. If the Node.js instance restarts in the middle of one of these timeouts, they are obviously all cleared on restart, which can cause some issues for these users. How would I go about persisting these timeouts, or are there any modules that already help with this?
I would store the start times and durations in Redis and restart incomplete timers when your application reloads. Some Redis modules:
This recipe can be found in it's original form on Stack Over Flow.