Node.js setInterval()在25天后停止执行 [英] Node.js setInterval() stops executing after 25 days

查看:244
本文介绍了Node.js setInterval()在25天后停止执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Node.js应用程序中,我使用 setInterval()每1小时运行一个特定的函数。该函数正常执行约25天,然后计时器停止触发。

In my Node.js application, I use setInterval() to run a specific function every 1 hour. The function is executed properly for about 25 days, then the timer stops firing.

25天似乎非常接近Node.js的 TIMEOUT_MAX (2 ^ 31毫秒≈25天),但我真的不明白为什么 setInterval()应该在那段时间后停止执行。

25 days seems awfully close to Node.js's TIMEOUT_MAX (2^31 milliseconds ≈ 25 days), but I don't really see why setInterval() should stop executing after that time.

更新:

我认为这可能是由Node.js中的以下错误引起的: setInterval回调函数意外停止#22149

I think this may have been caused by the following bug in Node.js: setInterval callback function unexpected halt #22149

推荐答案

似乎该错误(#22149 )已在 Node.js 10.9.0

它可能也值得这个错误似乎影响 setInterval() setTimeout()(如这里所述,所以解决方法是回调函数中的 setTimeout()不起作用。

It may be also worth noting that this bug seems to be influencing both setInterval() and setTimeout() (as reported here), so the workaround with setTimeout() in the callback function wouldn't work.

这篇关于Node.js setInterval()在25天后停止执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆