From ac20fadef6a102f3bd2ddee07367547217b43011 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 26 Sep 2025 08:11:44 +0200 Subject: [PATCH] Guards against empty cache arrays Prevents errors when attempting to process an empty cache. Deletes the cache entry if it is empty to avoid repeatedly attempting to process an invalid cache entry. --- services/promptGenerator.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/promptGenerator.ts b/services/promptGenerator.ts index 7b8c746..fc7f792 100644 --- a/services/promptGenerator.ts +++ b/services/promptGenerator.ts @@ -118,6 +118,12 @@ export class PromptGeneratorService { return null; } + // Guard against empty cache arrays + if (cached.length === 0) { + this.cache.delete(cacheKey); + return null; + } + const now = new Date().getTime(); const cacheTime = cached[0].timestamp.getTime();