diff options
Diffstat (limited to 'src/util.ts')
-rw-r--r-- | src/util.ts | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/util.ts b/src/util.ts index 9af95c7..f50118b 100644 --- a/src/util.ts +++ b/src/util.ts @@ -132,7 +132,14 @@ export async function withCache<T>(key: string, ttl: number | ((arg: T) => Date) ...(caches.get(key) ?? { data: undefined, nextUpdate: new Date(0) }), isFetching: true, }) - const data = await task() + const data = await task().catch(e => { + console.error(e) + caches.set(key, { + ...(caches.get(key) ?? { data: undefined, nextUpdate: new Date(0) }), + isFetching: false, + }) + return undefined + }) caches.set(key, { ...caches.get(key)!, isFetching: false, |