Unverified Commit abfd9945 authored by Neha Prasad's avatar Neha Prasad Committed by GitHub

Fix/zlib mem node (#89099)

- What?
Fixes zlib memory leak in Node.js 24 when requests are aborted.

- Why?
Compression streams weren't cleaned up on abort, causing memory to
accumulate.

- How?
Destroy the response on request abort/close to clean up compression
streams.

Closes NEXT-
fixes: #89091
parent eb828c68
......@@ -262,6 +262,12 @@ export async function initialize(opts: {
if (compress) {
// @ts-expect-error not express req/res
compress(req, res, () => {})
// Only on client abort: destroy response so compression streams are cleaned up
req.once('aborted', () => {
if (res.destroyed || res.writableFinished) return
res.destroy()
})
}
req.on('error', (_err) => {
// TODO: log socket errors?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment