Compare commits

...
1 Commits
Author SHA1 Message Date
Linden 4e29905179 fix(execute): check resourcestate is 'started' to resolve promise 2021-12-10 10:55:27 +00:00
2 changed files with 9 additions and 7 deletions

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ game 'common'
name 'oxmysql'
description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.'
version '1.8.6'
version '1.8.7'
url 'https://github.com/overextended/oxmysql'
author 'overextended'
use_fxv2_oal 'yes'
+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`);