Skip to content

Commit

Permalink
fix: dont emit an error on close if there wasnt one
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobheun authored and daviddias committed Nov 8, 2018
1 parent d259f1c commit 3b3f534
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/spdy-transport/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,15 @@ Connection.prototype._init = function init () {
self.emit('error', e)
})

this.socket.once('close', function onclose () {
var err = new Error('socket hang up')
err.code = 'ECONNRESET'
this.socket.once('close', function onclose (hadError) {
var err
if (hadError) {
err = new Error('socket hang up')
err.code = 'ECONNRESET'
}

self.destroyStreams(err)
self.emit('close', err)
self.emit('close')

if (state.pair) {
pool.put(state.pair)
Expand Down

0 comments on commit 3b3f534

Please sign in to comment.