Reputation: 50080
I want handle EADDRINUSE how it is described in API Doc nodejs but connect/express did not call the error event handler.
here is a example:
var connect = require('connect');
var app = connect();
app.use(function(req, res){
res.end('hello world\n');
});
app.on( 'error' , function(e) {
console.log('error event handler called');
});
app.listen(3000);
if I start the server two times, I got
throw arguments[1]; // Unhandled 'error' event
I tested it with connect 2.7.2.
Upvotes: 0
Views: 1246
Reputation: 50080
Since version 2.x, connect()
is no more a constructor for a net.Server
.
The 'net.Server' will be returned by the function listen(...)
.
So to get the example working, it should look like this:
var connect = require('connect');
var app = connect();
app.use(function(req, res){
res.end('hello world\n');
});
app.listen(3000).on( 'error' , function(e) {
console.log('error event handler called');
});
see also connect issue #749
Upvotes: 1