diff --git a/server-data/resources/[ox]/oxmysql/dist/build.js b/server-data/resources/[ox]/oxmysql/dist/build.js index 0e2b6593c..ba28a63ff 100644 --- a/server-data/resources/[ox]/oxmysql/dist/build.js +++ b/server-data/resources/[ox]/oxmysql/dist/build.js @@ -24767,6 +24767,11 @@ RegisterCommand( true ); +// src/utils/sleep.ts +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + // src/database/connection.ts var import_promise = __toESM(require_promise()); @@ -24781,15 +24786,8 @@ var pool; var isServerConnected = false; var dbVersion = ""; async function waitForConnection() { - if (!isServerConnected) { - return await new Promise((resolve) => { - (function wait() { - if (isServerConnected) { - return resolve(true); - } - setTimeout(wait); - })(); - }); + while (!isServerConnected) { + await sleep(0); } } async function createConnectionPool() { @@ -24813,11 +24811,8 @@ async function createConnectionPool() { } } async function getPoolConnection() { - if (!pool) { - await createConnectionPool(); - if (!pool) - return; - } + if (!isServerConnected) + await waitForConnection(); scheduleTick(); return pool.getConnection(); } @@ -25285,9 +25280,13 @@ ${err.message}`; }; // src/database/index.ts -setTimeout(() => { +setTimeout(async () => { setDebug(); - getPoolConnection(); + while (!isServerConnected) { + await createConnectionPool(); + if (!isServerConnected) + await sleep(3e4); + } }); setInterval(() => { setDebug(); diff --git a/server-data/resources/[ox]/oxmysql/fxmanifest.lua b/server-data/resources/[ox]/oxmysql/fxmanifest.lua index 9d13ca807..48372e21f 100644 --- a/server-data/resources/[ox]/oxmysql/fxmanifest.lua +++ b/server-data/resources/[ox]/oxmysql/fxmanifest.lua @@ -3,7 +3,7 @@ game 'common' name 'oxmysql' description 'Database wrapper for FXServer utilising node-mysql2 offering improved performance and security.' -version '2.7.6' +version '2.7.7' url 'https://github.com/overextended/oxmysql' author 'overextended'