mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 12:11:36 +00:00
give user a friendlier error when address() is unavailable due to noServer
This commit is contained in:
parent
a2bbaab485
commit
69976e80d7
@ -120,11 +120,14 @@ class Server extends EventEmitter {
|
||||
clientTracking: false,
|
||||
...(isObject(opts.ws) ? opts.ws : undefined)
|
||||
})
|
||||
if (!noServer) {
|
||||
|
||||
this.ws.address = () => {
|
||||
if (noServer) {
|
||||
throw new Error('address() unavailable with { noServer: true }')
|
||||
}
|
||||
return this.http.address()
|
||||
}
|
||||
}
|
||||
|
||||
this.ws.on('error', err => { this._onError(err) })
|
||||
this.ws.on('connection', (socket, req) => {
|
||||
// Note: socket.upgradeReq was removed in ws@3.0.0, so re-add it.
|
||||
|
Loading…
Reference in New Issue
Block a user