From 359c30fbda54f01f1f84227a96e9bd333664b21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20M=C3=B3ricz?= Date: Thu, 14 Nov 2024 19:49:34 +0100 Subject: [PATCH] fix(cache): don't cache on failure error code --- apps/api/src/scraper/scrapeURL/transformers/cache.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/api/src/scraper/scrapeURL/transformers/cache.ts b/apps/api/src/scraper/scrapeURL/transformers/cache.ts index 785047a1..e0c09c44 100644 --- a/apps/api/src/scraper/scrapeURL/transformers/cache.ts +++ b/apps/api/src/scraper/scrapeURL/transformers/cache.ts @@ -3,6 +3,8 @@ import { Meta } from ".."; import { CacheEntry, cacheKey, saveEntryToCache } from "../../../lib/cache"; export function saveToCache(meta: Meta, document: Document): Document { + if (document.metadata.statusCode! < 200 || document.metadata.statusCode! >= 300) return document; + if (document.rawHtml === undefined) { throw new Error("rawHtml is undefined -- this transformer is being called out of order"); }