mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 06:28:54 +00:00
refactor(database): waitForConnection
This commit is contained in:
1 parent
2a5e110e29
commit
bc8a874743
5 files changed
+30
-22
No files matched your search
@@ -5,6 +5,19 @@ import { typeCast } from '../utils/typeCast';
|
||||
let pool: Pool;
|
||||
let serverReady = false;
|
||||
|
||||
export async function waitForConnection() {
|
||||
if (!serverReady) {
|
||||
await new Promise<void>((resolve) => {
|
||||
(function wait() {
|
||||
if (serverReady) {
|
||||
return resolve();
|
||||
}
|
||||
setTimeout(wait);
|
||||
})();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
pool = createPool({
|
||||
connectTimeout: 60000,
|
||||
|
||||
Reference in new issue
Block a user