Kaelwd
Kaelwd
HHono
Created by Kaelwd on 9/6/2024 in #help
Trace when body is consumed
I have a middleware that's basically
if (cache.has(key)) {
return cache.get(key).clone()
}
await next()
if (c.res.ok) cache.set(key, c.res.clone())
if (cache.has(key)) {
return cache.get(key).clone()
}
await next()
if (c.res.ok) cache.set(key, c.res.clone())
cache is https://www.npmjs.com/package/node-cache with useClones=false This works great locally but when deployed to production it randomly throws TypeError: Response.clone: Body has already been consumed. on the first clone. Does anyone know if there's an easy way to tell what else is reading the body? This is the only thing using the cache instance so I don't understand how it's even possible. Server and dev both have node 22.8.0
3 replies