fix: throw error on write to destroyed socket

This commit is contained in:
Dirk McCormick 2019-05-01 16:32:07 +08:00 committed by Jacob Heun
parent 4a86c353e0
commit fb50de5cc6
No known key found for this signature in database
GPG Key ID: CA5A94C15809879F

View File

@ -38,9 +38,8 @@ class Libp2pSocket {
for await (const data of source) {
if (this._rawSocket.destroyed) {
const cOpts = this._ma.toOptions()
log('Cannot write %d bytes to destroyed socket %s:%s',
throw new Error('Cannot write %d bytes to destroyed socket %s:%s',
data.length, cOpts.host, cOpts.port)
return
}
const flushed = this._rawSocket.write(data)