Closed
Description
- Version: >= v4.x
- Platform: All
- Subsystem: net
It's possible to run listen()
on a net.Server
that's already listening to a port. The result is silent failure, with the side effect of changing the _connectionKey
and or _pipeName
.
More expected behavior would be to emit an error on the server's 'error'
event handler.
Example test:
const assert = require('assert');
const net = require('net');
const server = net.createServer();
server.on('error', () => {
process._rawDebug('server had an error');
});
server.listen(8080).listen(8081);
process.on('exit', () => {
assert.equal(server.address().port, 8080);
const key = server._connectionKey;
assert.equal(key.substr(key.lastIndexOf(':')), ':8080');
});