Skip to content

Commit 990c46c

Browse files
carlhoerbergbaelter
authored andcommitted
fixup! fix: propagate channel errors to connection and handle channel close properly
1 parent f9a3814 commit 990c46c

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/amqp-channel.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ export class AMQPChannel {
766766
* @param [err] - why the channel was closed
767767
*/
768768
setClosed(err?: Error): void {
769+
const closedByServer = err !== undefined
769770
err ||= new Error("Connection closed by client")
770771
if (!this.closed) {
771772
this.closed = true
@@ -776,10 +777,7 @@ export class AMQPChannel {
776777
this.unconfirmedPublishes.forEach(([, , reject]) => reject(err))
777778
this.unconfirmedPublishes.length = 0
778779

779-
// Call onerror for any error, whether from server or from a channel operation
780-
if (err.message !== "Connection closed by client") {
781-
this.onerror(err.message)
782-
}
780+
if (closedByServer) this.onerror(err.message)
783781
}
784782
}
785783

0 commit comments

Comments
 (0)