Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup
  • Loading branch information
oyyd committed Oct 30, 2018
commit f58c0f1c2e1fd49fd0f76c28ea7d75cb7fa65f9d
24 changes: 15 additions & 9 deletions test/parallel/test-net-server-listen-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,20 @@ function randomPipePath() {

// Test should emit "error" events when listening fails.
{
const srv = net.createServer()
.listen({
path: tmpdir.path,
writableAll: true,
}, common.mustNotCall());
const handlePath = randomPipePath();
const srv1 = net.createServer().listen({ path: handlePath }, () => {
// As the handlePath is in use, binding to the same address again should
// make the server emit an 'EADDRINUSE' error.
const srv2 = net.createServer()
.listen({
path: handlePath,
writableAll: true,
}, common.mustNotCall());

srv.on('error', common.mustCall((err) => {
assert.strictEqual(err.code, 'EADDRINUSE');
assert(/^listen EADDRINUSE: address already in use/.test(err.message));
}));
srv2.on('error', common.mustCall((err) => {
srv1.close();
assert.strictEqual(err.code, 'EADDRINUSE');
assert(/^listen EADDRINUSE: address already in use/.test(err.message));
}));
});
}