Request not ending in node.js (used to work) -
i have piece of code:
var app = require('http').createserver(function(req, res){ console.log(req); req.addlistener('end', function () { fileserver.serve(req, res); }); }); var statics = require('node-static'); var fileserver = new statics.server('./'); app.listen(1344, '127.0.0.1'); app.on('error', function(err){ console.log(err); })
it working fine, till made couple of changes, node gives error, , when went back, error wasn't there anymore, instead of work working before end
event not being fired. so, inside req.addlistener('end', function (){});
is not called.
and if run node.js uses same event, not being fired either. if end event of request broken. how can possible?
is not first time happens. last time ended re-installing node (after try lots of different things). prefer find solution, can understand problem!
note: original code include socket.io , other kind of connections, i've pasted piece of code app stuck on.
it useful know how debug problem!
@inspiredjw should credit pointing out, since had forgotten it, undoubtedly problem because of changes in readable streams. in order end
event called either have attach listener data
event, or have call stream.resume()
.
require('http').createserver(function(req, res){ req.addlistener('end', function () { // won't ever called in node v0.10.3 }); }); require('http').createserver(function(req, res){ req.addlistener('end', function () { // called in node v0.10.3 because called req.resume() }); req.resume(); }); require('http').createserver(function(req, res){ req.on('data', function (chunk) { }); req.addlistener('end', function () { // called because attached data event listener }); });
Comments
Post a Comment