Skip to content

Commit

Permalink
Update MySQL handler to add timeout for DNS query failures
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Irwin <[email protected]>

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.
  • Loading branch information
mikesir87 committed Dec 13, 2022
1 parent b4d6426 commit 8dff10b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/src/persistence/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8dff10b

Please sign in to comment.