Javascript 为什么瀑布这么慢?
我正在为Node.js使用异步模块(请参阅),我的问题是为什么瀑布这么慢? 执行这段代码大约需要4秒钟Javascript 为什么瀑布这么慢?,javascript,node.js,async.js,Javascript,Node.js,Async.js,我正在为Node.js使用异步模块(请参阅),我的问题是为什么瀑布这么慢? 执行这段代码大约需要4秒钟 App.post("/form", function(request, response) { Async.waterfall([ function(callback) { console.log("1."); callback(null, "some data"); }, function(data, callback) { console.l
App.post("/form", function(request, response) {
Async.waterfall([
function(callback) {
console.log("1.");
callback(null, "some data");
},
function(data, callback) {
console.log("2.");
callback(null, "some data");
},
function(data, callback) {
console.log("3.");
callback(null, "some data");
}
], function(error, document) {
console.log("4.");
console.log("Done.");
response.send(); // Takes 4 seconds
});
}
输出
1.
2.
// After 4 seconds
3.
4.
Done.
谢谢回复 这只是另一个Node.js错误 在另一个
进程中使用process.nextTick
。在挂起的http.ServerResponse
期间,nextTick
被中断
var http = require('http');
http.createServer(function(req, res) {
var now = new Date();
process.nextTick(function() {
process.nextTick(function() {
console.log(new Date() - now);
res.writeHead({});
res.end('foooooo');
});
});
}).listen(3000);
这需要一段时间,async.js
从通过process.nextTick
调用的其他回调中调用回调,然后触发上述错误
快速修复:在async.js
line63
modifiyasync.nextTick
中,仅使用setTimeout
错误:我已经就此提交了一份申请。什么是回应?这也是真实的代码吗?因为这会立即在这里执行。我使用的是Node.js v0.3.2-pre,您使用的是哪个版本?我也使用的是3.2-pre(5a87bd168d8fbeca7d48b9ddaa3b4e8a9336719c),但问题仍然是您的真实代码是什么样子的?@Ivo我刚刚编辑了我的问题,这是我的代码。(是的,我正在使用Express。)