From d2a9a433bb12e7397e34f2895a38bb2e79a75182 Mon Sep 17 00:00:00 2001 From: dunak-debug <19434539+dunak-debug@users.noreply.github.com> Date: Mon, 16 Aug 2021 21:42:18 +0200 Subject: [PATCH] fix(callback): use process._tickCallback() fix (process.nextTick()) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - this fixes whole issue with slow queries - https://github.com/alcoholiclobster/fivem-mongodb/blob/400ac6615a334d43531a7a1824f2e8b540246fe2/index.js#L105 - setImmediate will just make performance worse - now it also works in coroutine if yielded - also i´m not sure why tickCallback helps, if somebody know i would be glad to know :D - process.nextTick() is issue maybe, it works only for natives and not node functions - process.nextTick isn't firing until the socket timeout callback fires - discord conversation about it https://discord.com/channels/192358910387159041/433008322732490778/479523175869317130 --- src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.ts b/src/index.ts index 007b5ce..7799f57 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,6 +17,7 @@ global.exports( callback(false); console.log(error); }); + (process)._tickCallback(); } ); @@ -36,6 +37,7 @@ global.exports( callback(false); console.log(error); }); + (process)._tickCallback(); } ); @@ -55,6 +57,7 @@ global.exports( callback(false); console.log(error); }); + (process)._tickCallback(); } ); @@ -74,5 +77,6 @@ global.exports( callback(false); console.log(error); }); + (process)._tickCallback(); } );