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.
This commit is contained in:
AlexKucera committed 2025-09-26 08:11:44 +02:00
1 parent 520ac6e826
commit ac20fadef6
1 file changed
+6
+6
View File
@@ -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();