From 8b4b9afca3e3010509ee9025994bab0744d70533 Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Thu, 18 Aug 2022 01:25:48 -0400 Subject: [PATCH] Catch if saving response cache fails --- src/server.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index 0472392..3dfe722 100644 --- a/src/server.ts +++ b/src/server.ts @@ -287,7 +287,11 @@ export const cacheWrapper = async ( /* Store the fetched response as cacheKey Use waitUntil so you can return the response without blocking on writing to cache */ - event && event.waitUntil(cache.put(cacheKey, response.clone())); + try { + event && event.waitUntil(cache.put(cacheKey, response.clone())); + } catch (error) { + console.error((error as Error).stack); + } return response; /* Telegram sends this from Webpage Bot, and Cloudflare sends it if we purge cache, and we respect it.