From 68cdc65a893c7149b637a46efe5bbcb319cb42cd Mon Sep 17 00:00:00 2001
From: mat <github@matdoes.dev>
Date: Fri, 31 Dec 2021 02:29:32 -0600
Subject: fix memory leak, i hope

---
 src/hypixelCached.ts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'src')

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 })
 			}
-- 
cgit