Commit 0c633ff67d6c360cecef2ae8b4cc4b97a77da04d
Committed by
GitHub
1 parent
d31cb904
fix: Set cache overflow of the setTimeout Maximum delay value (#1742)
Showing
1 changed file
with
6 additions
and
1 deletions
src/utils/cache/memory.ts
... | ... | @@ -58,7 +58,12 @@ export class Memory<T = any, V = any> { |
58 | 58 | return value; |
59 | 59 | } |
60 | 60 | const now = new Date().getTime(); |
61 | - item.time = now + expires; | |
61 | + /** | |
62 | + * Prevent overflow of the setTimeout Maximum delay value | |
63 | + * Maximum delay value 2,147,483,647 ms | |
64 | + * https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value | |
65 | + */ | |
66 | + item.time = expires > now ? expires : now + expires; | |
62 | 67 | item.timeoutId = setTimeout( |
63 | 68 | () => { |
64 | 69 | this.remove(key); | ... | ... |