Reputation: 21
I'm having an issue where reloading (ctrl + c and then running again with node app
) a basic Node.js server (tried v0.12.0 and v0.12.7) on Windows 10 causes the server to hang for about 20 seconds before reloading. When using a tool like PM2 to watch my server, it errors out after any update to the file and the log shows an EADDRINUSE error.
I boiled this down to the most simple possible example (thinking it might be an issue with Express) but it's still happening with the basic example from the Node.js documentation:
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(3030);
console.log('Server running at http://127.0.0.1:3030/');
I've checked that nothing else is running on port 3030. I've also tried different port numbers. It just seems that the Node.js process is not shutting down and releasing the port in a timely manner. I've also tried using ctrl+break, and also capturing the SIGINT and manually calling process.exit(). I can confirm that it catches the signal, but it still hangs as described.
I first noticed this shortly after upgrading to Windows 10 from 7, and was not having issues before, so I would think this is the most likely culprit. I have a dual-boot with Ubuntu 14.04, and I am having no issues there with the same code.
Upvotes: 1
Views: 390
Reputation: 21
I'm no longer having the problem I described: it was likely something very specific to my setup since it wasn't reported anywhere else. I have since updated to Node 4.2.1 and installed various Windows updates, so hard to say what the original cause was.
Upvotes: 1