fix(cache): don't cache on failure error code
This commit is contained in:
@@ -3,6 +3,8 @@ import { Meta } from "..";
|
|||||||
import { CacheEntry, cacheKey, saveEntryToCache } from "../../../lib/cache";
|
import { CacheEntry, cacheKey, saveEntryToCache } from "../../../lib/cache";
|
||||||
|
|
||||||
export function saveToCache(meta: Meta, document: Document): Document {
|
export function saveToCache(meta: Meta, document: Document): Document {
|
||||||
|
if (document.metadata.statusCode! < 200 || document.metadata.statusCode! >= 300) return document;
|
||||||
|
|
||||||
if (document.rawHtml === undefined) {
|
if (document.rawHtml === undefined) {
|
||||||
throw new Error("rawHtml is undefined -- this transformer is being called out of order");
|
throw new Error("rawHtml is undefined -- this transformer is being called out of order");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user