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); });