From bccd9191cdc12d78d9add63885889fa9950ba48f Mon Sep 17 00:00:00 2001 From: swarupio Date: Sun, 31 May 2026 01:46:56 +0530 Subject: [PATCH 1/2] test(cache): verify TTLCache behavior for NaN TTL value (#1399) --- lib/cache.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/cache.test.ts b/lib/cache.test.ts index a0317461..e434fb73 100644 --- a/lib/cache.test.ts +++ b/lib/cache.test.ts @@ -431,6 +431,23 @@ describe('TTLCache', () => { cache.clear(); expect(cache.size()).toBe(0); + cache.destroy(); + }); + // FIX: New test targeting the NaN boundary for Issue #1399 + it('resolves NaN TTL to the default standard TTL duration', () => { + vi.useFakeTimers(); + const cache = new TTLCache(); + + // Setting with NaN should not throw; it should fallback to the default TTL + expect(() => cache.set('nan-key', 'value', NaN)).not.toThrow(); + + // The item should be successfully stored + expect(cache.get('nan-key')).toBe('value'); + + // Advance by a small amount to ensure it didn't instantly expire + vi.advanceTimersByTime(1000); + expect(cache.get('nan-key')).toBe('value'); + cache.destroy(); }); }); From b601496b4965e98fb0a6618ac770e3664bc79c77 Mon Sep 17 00:00:00 2001 From: swarupio Date: Sun, 31 May 2026 13:21:52 +0530 Subject: [PATCH 2/2] fix: resolve merge conflict with upstream main --- lib/cache.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/cache.test.ts b/lib/cache.test.ts index 14eac7f6..24af74f5 100644 --- a/lib/cache.test.ts +++ b/lib/cache.test.ts @@ -549,7 +549,7 @@ describe('TTLCache', () => { cache.destroy(); }); -// FIX: New test targeting the NaN boundary for Issue #1399 + // FIX: New test targeting the NaN boundary for Issue #1399 it('resolves NaN TTL to the default standard TTL duration', () => { vi.useFakeTimers(); const cache = new TTLCache(); @@ -701,5 +701,4 @@ describe('DistributedCache', () => { ); cache.destroy(); }); - }); });