From 4b57bacc29f70b2001ba4c57c18d16b6817f40e4 Mon Sep 17 00:00:00 2001 From: David Klakurka Date: Thu, 19 Feb 2026 17:36:23 -0800 Subject: [PATCH 1/2] Attempted fix for dashboard not loading sometimes --- redis/index.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/redis/index.ts b/redis/index.ts index 3fc5f35d4..4f45d66f9 100644 --- a/redis/index.ts +++ b/redis/index.ts @@ -76,8 +76,10 @@ export const CacheSet = { type MethodName = 'dashboardData' | 'paymentList' | 'addressBalance' | 'paymentsCount' +type InFlightCalls = Partial>> + interface PendingCalls { - [userId: string]: Set + [userId: string]: InFlightCalls } export class CacheGet { @@ -89,21 +91,25 @@ export class CacheGet { fn: () => Promise ): Promise { if (this.pendingCalls[userId] === undefined) { - this.pendingCalls[userId] = new Set() + this.pendingCalls[userId] = {} } - if (this.pendingCalls[userId].has(methodName)) { - throw new Error(`Method "${methodName}" is already being executed for user "${userId}".`) + const existingCall = this.pendingCalls[userId][methodName] + if (existingCall !== undefined) { + return await (await existingCall as Promise) } - this.pendingCalls[userId].add(methodName) + const pendingCall = fn() + this.pendingCalls[userId][methodName] = pendingCall as Promise try { - return await fn() + return await pendingCall } finally { - this.pendingCalls[userId].delete(methodName) - if (this.pendingCalls[userId].size === 0) { - this.pendingCalls[userId] = undefined as unknown as Set + if (this.pendingCalls[userId]?.[methodName] === pendingCall) { + this.pendingCalls[userId][methodName] = undefined + } + if (this.pendingCalls[userId] !== undefined && Object.keys(this.pendingCalls[userId]).length === 0) { + this.pendingCalls[userId] = {} } } } From ac39238ded922afbfafea1501f361c71f4c17332 Mon Sep 17 00:00:00 2001 From: David Klakurka Date: Tue, 3 Mar 2026 23:03:36 -0800 Subject: [PATCH 2/2] Cleanup --- redis/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis/index.ts b/redis/index.ts index 4f45d66f9..9710e6e1f 100644 --- a/redis/index.ts +++ b/redis/index.ts @@ -96,7 +96,7 @@ export class CacheGet { const existingCall = this.pendingCalls[userId][methodName] if (existingCall !== undefined) { - return await (await existingCall as Promise) + return await (existingCall as Promise) } const pendingCall = fn()