From e3e7623c27b21d53a156611073efb02cba9a5b39 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 14 Oct 2023 12:48:57 +0300 Subject: [PATCH] throw clear error about unavailable db nodes --- src/MariaDB.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MariaDB.ts b/src/MariaDB.ts index b8b6e27..04289f6 100644 --- a/src/MariaDB.ts +++ b/src/MariaDB.ts @@ -337,6 +337,9 @@ class MariaDB const pool = this.#pool; if (nodeName) { + const available = this.#nodes.filter(n => n.status === 'synced'); + if (!available.length) + throw new Error('No nodes available for query'); const node = this.#nodes.find(n => n.name === nodeName); if (!node) { @@ -358,7 +361,7 @@ class MariaDB this.#logger.debug(`Selected node ${nodeName} for query`); return pool.of(nodeName ?? '*').getConnection((err, conn) => { - if (err) + if (err) return reject(err); return resolve(conn); });