cache: use the old response body to prevent memory leaks

This commit is contained in:
Alex Gleason
2024-04-13 14:36:31 -05:00
parent afed0a0b34
commit ff3d8e3f90

View File

@@ -19,7 +19,9 @@ export const cache = (opts: CacheOpts): MiddlewareHandler => {
await next();
const res = c.res.clone();
if (res.status < 500) {
const old = response;
response = res;
old?.text(); // Prevent memory leaks.
}
return res;
}