From 8dff10bcaace379a18b70fda8a49238e8c0e20f9 Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Tue, 13 Dec 2022 16:53:36 -0500 Subject: [PATCH] Update MySQL handler to add timeout for DNS query failures Signed-off-by: Michael Irwin I was helping troubleshoot an issue with someone, who ended up having a typo in their compose file where the MySQL service was using the name "msyql", which obviously causes DNS to fail. But, since the db init doesn't time out, it just looks hung. This fixes that. --- app/src/persistence/mysql.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/persistence/mysql.js b/app/src/persistence/mysql.js index 3e03a70..9fc4077 100644 --- a/app/src/persistence/mysql.js +++ b/app/src/persistence/mysql.js @@ -21,7 +21,12 @@ async function init() { const password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD; const database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; - await waitPort({ host, port : 3306}); + await waitPort({ + host, + port: 3306, + timeout: 10000, + waitForDns: true, + }); pool = mysql.createPool({ connectionLimit: 5,