fix: resolve updateCache() so race condition does not happen

This commit is contained in:
P. Reis 2024-04-18 20:54:29 -03:00
parent c62c31a171
commit b5844ff06e

View file

@ -34,7 +34,7 @@ export const cache = (opts: CacheOpts): MiddlewareHandler => {
if (response && expired) {
debug('Serving stale cache, rebuilding', c.req.url);
const stale = response.clone();
updateCache();
await updateCache();
await new Promise((resolve) => setTimeout(resolve, 0));
return stale;
}