mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
cache: use the old response body to prevent memory leaks
This commit is contained in:
parent
afed0a0b34
commit
ff3d8e3f90
1 changed files with 2 additions and 0 deletions
|
|
@ -19,7 +19,9 @@ export const cache = (opts: CacheOpts): MiddlewareHandler => {
|
||||||
await next();
|
await next();
|
||||||
const res = c.res.clone();
|
const res = c.res.clone();
|
||||||
if (res.status < 500) {
|
if (res.status < 500) {
|
||||||
|
const old = response;
|
||||||
response = res;
|
response = res;
|
||||||
|
old?.text(); // Prevent memory leaks.
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue