aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-31 02:29:32 -0600
committermat <github@matdoes.dev>2021-12-31 02:29:32 -0600
commit68cdc65a893c7149b637a46efe5bbcb319cb42cd (patch)
tree78e783f9ebe564bb7f51b63c302a5f1504f39010 /src
parent1e8e1f82ee0ad23fbd879630d81867615c394a16 (diff)
downloadskyblock-api-68cdc65a893c7149b637a46efe5bbcb319cb42cd.tar.gz
skyblock-api-68cdc65a893c7149b637a46efe5bbcb319cb42cd.tar.bz2
skyblock-api-68cdc65a893c7149b637a46efe5bbcb319cb42cd.zip
fix memory leak, i hope
Diffstat (limited to 'src')
-rw-r--r--src/hypixelCached.ts4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts
index cdf1e63..26e3dc5 100644
--- a/src/hypixelCached.ts
+++ b/src/hypixelCached.ts
@@ -69,7 +69,9 @@ interface KeyValue {
function waitForCacheSet(cache: NodeCache, key?: string, value?: string): Promise<KeyValue> {
return new Promise((resolve, reject) => {
const listener = (setKey, setValue) => {
- if (((setKey === key) || (value && setValue === value)) && typeof setValue === 'string') {
+ // we check that the setValue isn't a promise because it's often
+ // set as a promise for this exact function
+ if (((setKey === key) || (value && setValue === value)) && (!setValue.then)) {
cache.removeListener('set', listener)
return resolve({ key: setKey, value: setValue })
}