Skip to content

Commit

Permalink
fix: don't call onConnect automatically (nodejs#3407)
Browse files Browse the repository at this point in the history
In some edge cases this causes issues. Leave it to the user to
handle if necessary.
  • Loading branch information
ronag committed Jul 17, 2024
1 parent d61af69 commit c1f7d2a
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions lib/handler/decorator-handler.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict'

const assert = require('node:assert')
const noop = () => {}

module.exports = class DecoratorHandler {
#handler
#onConnectCalled = false
#onCompleteCalled = false
#onErrorCalled = false

Expand All @@ -17,16 +15,10 @@ module.exports = class DecoratorHandler {
}

onConnect (...args) {
this.#onConnectCalled = true
return this.#handler.onConnect?.(...args)
}

onError (...args) {
if (!this.#onConnectCalled) {
this.#onConnectCalled = true
this.#handler.onConnect?.(noop)
}

this.#onErrorCalled = true
return this.#handler.onError?.(...args)
}
Expand Down

0 comments on commit c1f7d2a

Please sign in to comment.