mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 06:28:54 +00:00
fix(execute): check resourcestate is 'started' to resolve promise
This commit is contained in:
1 parent
78ce45f1de
commit
4e29905179
2 files changed
+9
-7
No files matched your search
+1
-1
@@ -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
@@ -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`);
|
||||
|
||||
Reference in new issue
Block a user