From 412ed921be20494e87f5f6b5c9a65ad2f207d304 Mon Sep 17 00:00:00 2001 From: Jason Walton Date: Mon, 24 Oct 2022 10:53:23 -0400 Subject: [PATCH] fix: Fail immediately for a bad password on latest amqplib. --- package.json | 2 +- src/AmqpConnectionManager.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9c36e17..43448ba 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@types/whatwg-url": "^11.0.0", "@typescript-eslint/eslint-plugin": "^5.9.0", "@typescript-eslint/parser": "^5.9.0", - "amqplib": "^0.8.0", + "amqplib": "^0.10.3", "chai": "^4.1.2", "chai-as-promised": "^7.1.1", "chai-jest": "^1.0.2", diff --git a/src/AmqpConnectionManager.ts b/src/AmqpConnectionManager.ts index 2ed41c6..99ea70b 100644 --- a/src/AmqpConnectionManager.ts +++ b/src/AmqpConnectionManager.ts @@ -220,9 +220,9 @@ export default class AmqpConnectionManager extends EventEmitter implements IAmqp this._connect(); let reject: (reason?: any) => void; - const onConnectFailed = ({ err }: { err: any }) => { - // Ignore disconnects caused by dead servers etc., but throw on operational errors like bad credentials. - if (err.isOperational) { + const onConnectFailed = ({ err }: { err: Error }) => { + // Ignore disconnects caused bad credentials. + if (err.message.includes('ACCESS-REFUSED') || err.message.includes('403')) { reject(err); } };