Skip to content

Commit 69976e8

Browse files
committed
give user a friendlier error when address() is unavailable due to noServer
1 parent a2bbaab commit 69976e8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

server.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,14 @@ class Server extends EventEmitter {
120120
clientTracking: false,
121121
...(isObject(opts.ws) ? opts.ws : undefined)
122122
})
123-
if (!noServer) {
124-
this.ws.address = () => {
125-
return this.http.address()
123+
124+
this.ws.address = () => {
125+
if (noServer) {
126+
throw new Error('address() unavailable with { noServer: true }')
126127
}
128+
return this.http.address()
127129
}
130+
128131
this.ws.on('error', err => { this._onError(err) })
129132
this.ws.on('connection', (socket, req) => {
130133
// Note: socket.upgradeReq was removed in [email protected], so re-add it.

0 commit comments

Comments
 (0)