I have this 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 worked very well until I made a couple of changes, node gives an error, and when I returned, this error no longer existed, but instead of working as if it worked before the end event does not fire. So, nothing inside req.addListener('end', function (){}); not called.
And even if I fire another node.js that uses the same event, it also fails. Similarly, if the request termination event is interrupted. But how is this possible?
This is not the first time this has happened. Last time I finished reinstalling node (after I tried many different things). I would rather find a solution, so I can understand the problem!
NOTE. The source code includes socket.io and other types of connections, but I just pasted a piece of code, this application is stuck.
It may also be useful to learn how to debug a problem!
source share