Skip to content

Commit

Permalink
refactor: make http2 session handle shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
metcoder95 committed Apr 26, 2023
1 parent f1b0e78 commit 88696b8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,10 @@ function destroy (stream, err) {

// HTTP/2 - It causes to throw uncaught exceptions due to the
// error passed down the socket.destroy
if (stream.alpnProtocol === 'h2' &&
const isHTTP2 = stream.alpnProtocol === 'h2' &&
Object.getPrototypeOf(err).constructor === ClientDestroyedError
) {
stream.destroy()
} else {
stream.destroy(err)
}

stream.destroy(!isHTTP2 ? err : null)
} else if (err) {
process.nextTick((stream, err) => {
stream.emit('error', err)
Expand Down

0 comments on commit 88696b8

Please sign in to comment.