Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit 4e29905

Browse files
committed
fix(execute): check resourcestate is 'started' to resolve promise
1 parent 78ce45f commit 4e29905

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lua/fxmanifest.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ game 'common'
33

44
name 'oxmysql'
55
description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.'
6-
version '1.8.6'
6+
version '1.8.7'
77
url 'https://github.com/overextended/oxmysql'
88
author 'overextended'
99
use_fxv2_oal 'yes'

src/execute.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ import { FormatError } from './errors';
55

66
let isReady = false;
77

8-
const serverReady = () => {
9-
return new Promise(() => {
10-
setTimeout(() => {
11-
return true;
12-
});
8+
const serverReady = async () => {
9+
return new Promise((resolve) => {
10+
const id = setInterval(() => {
11+
if (GetResourceState(resourceName) == 'started') resolve(id);
12+
}, 50);
13+
}).then((id) => {
14+
clearInterval(id);
15+
isReady = true;
1316
});
1417
};
1518

1619
setImmediate(async () => {
1720
try {
1821
await pool.query(isolationLevel);
19-
isReady = true;
2022
console.log(`^2Database server connection established!^0`);
2123
} catch (error) {
2224
console.log(`^3Unable to establish a connection to the database! [${error.code}]\n${error.message}^0`);

0 commit comments

Comments
 (0)