From 0c633ff67d6c360cecef2ae8b4cc4b97a77da04d Mon Sep 17 00:00:00 2001 From: chenls Date: Fri, 25 Mar 2022 23:40:15 +0800 Subject: [PATCH] fix: Set cache overflow of the setTimeout Maximum delay value (#1742) --- src/utils/cache/memory.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/cache/memory.ts b/src/utils/cache/memory.ts index 2188ed01..08a0a647 100644 --- a/src/utils/cache/memory.ts +++ b/src/utils/cache/memory.ts @@ -58,7 +58,12 @@ export class Memory { return value; } const now = new Date().getTime(); - item.time = now + expires; + /** + * Prevent overflow of the setTimeout Maximum delay value + * Maximum delay value 2,147,483,647 ms + * https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value + */ + item.time = expires > now ? expires : now + expires; item.timeoutId = setTimeout( () => { this.remove(key);