mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 02:21: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,
|
clientTracking: false,
|
||||||
...(isObject(opts.ws) ? opts.ws : undefined)
|
...(isObject(opts.ws) ? opts.ws : undefined)
|
||||||
})
|
})
|
||||||
if (!noServer) {
|
|
||||||
this.ws.address = () => {
|
this.ws.address = () => {
|
||||||
return this.http.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('error', err => { this._onError(err) })
|
||||||
this.ws.on('connection', (socket, req) => {
|
this.ws.on('connection', (socket, req) => {
|
||||||
// Note: socket.upgradeReq was removed in ws@3.0.0, so re-add it.
|
// Note: socket.upgradeReq was removed in ws@3.0.0, so re-add it.
|
||||||
|
Loading…
Reference in New Issue
Block a user