Так?
try {
await sqlConnection()
}
catch (e) {
console.log(e);
}
function sqlConnection() {
var attempts = 5;
return new Promise(function (resolve, reject) {
con.connect(function connect(err) {
if (err) {
if(attempts--) con.connect(connect);
else reject(err);
} else {
console.log("Connected to mysql");
resolve();
}
})
})
}