This is a Next.js project bootstrapped with create-next-app.
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
Use Node.js version 24.13.0.
Build the project:
npm run buildRun production build with --inspect option:
NODE_OPTIONS=--inspect ./node_modules/.bin/next startFollow http://localhost:3000/ open Node.js DevTools and make an initial memory snapshot (do GC before). Then, to emulate request cancellation, you can run the snippet in the browser console:
const ATTEMPT_COUNT = 50
const ATTEMPT_TIMEOUT_MS = 10
const REQUEST_COUNT = 10
const REQUEST_TIMEOUT_MS = 500
for await (const attemptIndex of Array.from({ length: ATTEMPT_COUNT }).keys()) {
for (const requestIndex of Array.from({ length: REQUEST_COUNT }).keys()) {
fetch('http://localhost:3000/', {
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
})
}
await new Promise((resolve) => {
setTimeout(resolve, ATTEMPT_TIMEOUT_MS)
})
}Make another snapshot after it (call GC before) and compare them. You should see a similar picture:
Node / zlib_memory chunks won't dissapper, they will appear more and more during testing. If you disable compression in Next.js config with the option compress false, the issue is gone.
