cache: use the old response body to prevent memory leaks
This commit is contained in:
parent
afed0a0b34
commit
ff3d8e3f90
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue