Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
fix: cannot catch EADDRINUSE (#198)
Browse files Browse the repository at this point in the history
related to #184
  • Loading branch information
mpetrunic authored Dec 8, 2022
1 parent e549691 commit c7312db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ coverage
.nyc_output
docs
dist
.coverage
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"@multiformats/multiaddr-to-uri": "^9.0.2",
"abortable-iterator": "^4.0.2",
"err-code": "^3.0.1",
"it-ws": "^5.0.0",
"it-ws": "^5.0.6",
"p-defer": "^4.0.0",
"p-timeout": "^6.0.0",
"wherearewe": "^2.0.1"
Expand Down
9 changes: 9 additions & 0 deletions test/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint max-nested-callbacks: ["error", 6] */

import https from 'https'
import http from 'http'
import fs from 'fs'
import { expect } from 'aegir/chai'
import { multiaddr } from '@multiformats/multiaddr'
Expand Down Expand Up @@ -102,6 +103,14 @@ describe('listen', () => {
void listener.listen(ma)
})

it('should error on starting two listeners on same address', async () => {
listener = ws.createListener({ upgrader })
const dumbServer = http.createServer()
await new Promise<void>(resolve => dumbServer.listen(ma.toOptions().port, resolve))
await expect(listener.listen(ma)).to.eventually.rejectedWith('listen EADDRINUSE')
await new Promise<void>(resolve => dumbServer.close(() => resolve()))
})

it('listen, check for the close event', (done) => {
const listener = ws.createListener({ upgrader })

Expand Down

0 comments on commit c7312db

Please sign in to comment.