Skip to content

Commit

Permalink
fix: ensure onConnect is always called
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Jun 14, 2024
1 parent 077531a commit d2ddecc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/core/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const { headerNameLowerCasedRecord } = require('./constants')
const invalidPathRegex = /[^\u0021-\u00ff]/

const kHandler = Symbol('handler')
const noop = () => {}

class Request {
constructor (origin, {
Expand Down Expand Up @@ -295,6 +296,14 @@ class Request {
}
this.aborted = true

if (!this.abort) {
// Make sure to always call onConnect even on errors to avoid
// a common user mistake of assuming that onConnect is always
// called before any other hook.
this.abort = noop
this[kHandler].onConnect(noop)
}

return this[kHandler].onError(error)
}

Expand Down

0 comments on commit d2ddecc

Please sign in to comment.