递归process.nextTick警告 [英] Recursive process.nextTick warning
问题描述
作为我的应用程序的一部分,我有以下几行代码:
As part of my app, I have the following lines of code:
process.nextTick(function() {
// pre-populate cache with all users
console.log('scanning users table in order to pre-populate cache');
tables.users.scan(function(err, users) {
if (err) {
console.error('unable to scan users database in order to pre-populate cache');
return;
}
console.log('found %d users in database', users.length);
});
});
在ubuntu中运行应用程序给了我
running the app in ubuntu gives me
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
RangeError: Maximum call stack size exceeded
在OSX上运行正常完全没有警告。
running on OSX is working good no warnings at all.
两者都运行相同的节点版本 v0.10.24
。
Both run the same node version v0.10.24
.
删除此代码块可解决此问题。我试图弄清楚这里发生了什么。
Removing this block of code solves the problem. I am trying to figure out what's going on here.
尝试使用运行节点 - trace-deprecation
flag显示
Trying to run node with --trace-deprecation
flag shows
Trace: (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
at maxTickWarn (node.js:377:17)
at process.nextTick (node.js:480:9)
at onwrite (_stream_writable.js:260:15)
at WritableState.onwrite (_stream_writable.js:97:5)
at WriteStream.Socket._write (net.js:651:5)
at doWrite (_stream_writable.js:221:10)
at writeOrBuffer (_stream_writable.js:211:5)
at WriteStream.Writable.write (_stream_writable.js:180:11)
at WriteStream.Socket.write (net.js:613:40)
at Console.warn (console.js:61:16)
at Console.trace (console.js:95:8)
at maxTickWarn (node.js:377:17)
以运行 - throw-deprecation
给出
Error: (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
at maxTickWarn (node.js:375:15)
at process.nextTick (node.js:480:9)
at Cursor.each (/var/www/node_modules/mongojs/node_modules/mongodb/lib/mongodb/cursor.js:184:13)
at /var/www/node_modules/mongojs/node_modules/mongodb/lib/mongodb/cursor.js:191:16
at Cursor.nextObject (/var/www/node_modules/mongojs/node_modules/mongodb/lib/mongodb/cursor.js:540:5)
at /var/www/node_modules/mongojs/node_modules/mongodb/lib/mongodb/cursor.js:187:12
at process._tickCallback (node.js:415:13)
非常感谢任何帮助。
10x
推荐答案
事实证明问题出在我在我的应用程序中使用的模块之一 - mongojs
。该问题在该模块的更高版本中得到解决,我只需要更新我的 package.json
。
It turns out the problem was in one of the modules I used in my app - mongojs
. The problem was solved in a later version of the module, I just needed to update my package.json
.
Jamis Charles评论如何使用 node --throw-deprecation app.js
运行我的应用程序(或 - trace-deprecation
)向我展示了错误的堆栈跟踪,这导致了我的罪魁祸首模块。
Jamis Charles comment about running my app with node --throw-deprecation app.js
(or --trace-deprecation
) showed me the stack trace of the error that led me to the culprit module.
我仍然不确定为什么问题出现在Ubuntu而不是我的MBA上。 ..
I'm still not sure why the problem showed in Ubuntu and not on my MBA...
这篇关于递归process.nextTick警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!