From a4099dff9e98599c0e899209e6768af4aa9eedbc Mon Sep 17 00:00:00 2001 From: Steven H Date: Fri, 15 Mar 2024 13:47:31 +0000 Subject: [PATCH] Remove awaiting for local caches to set their values whilst we investigate hanging pages. (#275) --- src/lib/async.ts | 2 +- src/lib/cache/cache.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/async.ts b/src/lib/async.ts index 33788de94..5e0523777 100644 --- a/src/lib/async.ts +++ b/src/lib/async.ts @@ -85,7 +85,7 @@ export async function race( const done = () => { resolved = true; if (timeoutId) { - clearTimeout(timeoutId!); + clearTimeout(timeoutId); } if (blockTimeoutId) { clearTimeout(blockTimeoutId); diff --git a/src/lib/cache/cache.ts b/src/lib/cache/cache.ts index fd8a53eaa..c385a4f3d 100644 --- a/src/lib/cache/cache.ts +++ b/src/lib/cache/cache.ts @@ -177,12 +177,16 @@ export function cache( // If the resolution came from a fetch (fromBackend is undefined), we don't need to update caches as it was // done in the revalidate function above. if (fromBackend?.replication === 'global') { - await waitUntil( + // Write and await to the memory cache, so future requests are guaranteed to hit it. + await memoryCache.set(key, savedEntry); + + // Write to other local caches, but don't await (debugging hanging pages) + waitUntil( Promise.all( cacheBackends .filter( (backend) => - backend.name !== backendName && backend.replication === 'local', + backend.name !== backendName && backend.name !== memoryCache.name && backend.replication === 'local', ) .map((backend) => backend.set(key, savedEntry)), ),