throw clear error about unavailable db nodes

This commit is contained in:
Erik 2023-10-14 12:48:57 +03:00
parent a82dacdc30
commit e3e7623c27

View File

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