fix(execute): check resourcestate is 'started' to resolve promise

This commit is contained in:
Linden committed 2021-12-10 10:55:27 +00:00
1 parent 78ce45f1de
commit 4e29905179
2 files changed
+9 -7

No files matched your search

+8 -6
View File
@@ -5,18 +5,20 @@ import { FormatError } from './errors';
let isReady = false;
const serverReady = () => {
return new Promise(() => {
setTimeout(() => {
return true;
});
const serverReady = async () => {
return new Promise((resolve) => {
const id = setInterval(() => {
if (GetResourceState(resourceName) == 'started') resolve(id);
}, 50);
}).then((id) => {
clearInterval(id);
isReady = true;
});
};
setImmediate(async () => {
try {
await pool.query(isolationLevel);
isReady = true;
console.log(`^2Database server connection established!^0`);
} catch (error) {
console.log(`^3Unable to establish a connection to the database! [${error.code}]\n${error.message}^0`);