node.js 中 setTimeout 的最大时间限制 [英] Maximum time limit of setTimeout in node.js
问题描述
我已经在 node 中注册了一些 setTimeout
函数,如下所示.
I have registered some setTimeout
functions in node like below.
//Formula: minutes * 60 > seconds * 1000 > miliseconds.
setTimeout(() => {console.log("One minute")}, 1 * 60 * 1000) //delay 60000
setTimeout(() => {console.log("Five minutes")}, 5 * 60 * 1000) //delay 300000
setTimeout(() => {console.log("Ten minutes")}, 10 * 60 * 1000) //delay 600000
setTimeout(() => {console.log("Thirty minutes")}, 30 * 60 * 1000) //delay 1800000
setTimeout(() => {console.log("One hour")}, 60 * 60 * 1000) //delay 3600000
setTimeout(() => {console.log("Two hours")}, 120 * 60 * 1000) //delay 7200000
setTimeout(() => {console.log("Five hours")}, 300 * 60 * 1000) //delay 18000000
现在的问题是 setTimeout
在我阅读 setTimeout
文档时需要 10 分钟 无法工作,它支持 24.8 天.
Now the issue is setTimeout
that take more than 10 minutes is not working when I read setTimeout
documentation it's support 24.8 days.
当delay大于2147483647或小于1时,delay设置为1
When delay is larger than 2147483647 or less than 1, the delay will be set to 1
所有延迟的值都小于 2147483647 比为什么它不工作???
All delay's value is less than 2147483647 than why it is not working ???
推荐答案
当我在 node.js
存储库上创建问题时,我终于得到了答案,基本上它不是 node.js 而是 heroku 问题.
在 heroku 中,免费 dynos 是独一无二的,因为它们会在 30 分钟不活动后进入睡眠状态,因此超过 30 分钟的时间不起作用
Github 问题
Finally I got answer when I created issue on node.js
repo, basically it's not node.js but heroku issue.
In heroku free dynos are unique because they go to sleep after 30 minutes of inactivity so more than 30 minutes of time is not working
Github issue
这篇关于node.js 中 setTimeout 的最大时间限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!