'setInterval() and setTimeout() do nothing on heroku

My Node.js app works as intended and runs without errors on VSCode. However, setInterval() and setTimeout() do nothing once my app runs on heroku. I knew this because I wrote console.log() everywhere and looked at the heroku log of my app. None of the console.log() statements inside a setInterval() or setTimeout() were executed.

Surprisingly, all other functions of this app worked on heroku.

Here is the segment of code.

var refreshIntervalId = setInterval(() => {
    config = require("./config.json");
    // console.log("index line 44: entered loop");
    if (config["reminder#" + fixedCount] == undefined) return clearInterval(refreshIntervalId);
    config["reminder#" + fixedCount]["time"] -= 5 * 60 * 1000;
    if (config["reminder#" + fixedCount]["time"] > 0) updateJson();
}, (5 * 60 * 1000));

setTimeout(() => {
    const color = "#" + hexCodes[~~(Math.random() * hexCodes.length)], userID = config["reminder#" + fixedCount]["user"];
    const userObject = client.users.cache.get(userID);
    let sendReminder = new Discord.MessageEmbed()
        .setTitle(`Reminder to ${userObject.username.split("#")[0]}`)
        .setColor(color)
        .setDescription(config["reminder#" + fixedCount]["content"]);
    userObject.send({embeds: [sendReminder]}).catch(err => { });
    delete config["reminder#" + fixedCount];
    updateJson();
}, config["reminder#" + fixedCount]["time"]);

Any idea why this happened?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source