nextjs - 💡(How to fix) Fix zlib memory leak Node.js 24 [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#89090Fetched 2026-04-08 02:03:23
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×2closed ×1commented ×1issue_type_added ×1

Code Example

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)
      })
    }

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:07:05 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 24.13.0
  npm: 11.6.2
  Yarn: 1.22.22
  pnpm: 10.28.2
Relevant Packages:
  next: 16.1.5 // Latest available version is detected (16.1.5).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/izorg/next-app

To Reproduce

  1. Use Node.js version 24.13.0
  2. npm run build
  3. NODE_OPTIONS=--inspect ./node_modules/.bin/next start
  4. http://localhost:3000/
  5. Call GC & make memory snapshot
  6. Run snippet in 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)
      })
    }
  7. Call GC & make memory snapshot
  8. Compare snapshots and see Node / zlib_memory positive delta

Current vs. Expected behavior

Expect memory to still more or less on the same level

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:07:05 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 24.13.0
  npm: 11.6.2
  Yarn: 1.22.22
  pnpm: 10.28.2
Relevant Packages:
  next: 16.1.5 // Latest available version is detected (16.1.5).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Performance

Which stage(s) are affected? (Select all that apply)

next start (local)

Additional context

I tested on 24.0.0, the issue is still there. I tested on lates 22.22.0 and there is no issue with zlib.

extent analysis

TL;DR

  • The issue can be mitigated by downgrading Node.js to version 22.22.0, where the zlib memory leak is not present.

Guidance

  • Verify that the memory leak is indeed caused by the zlib module by analyzing the memory snapshots taken before and after running the provided snippet.
  • Test the application with different Node.js versions to confirm that the issue is specific to versions 24.0.0 and later.
  • Consider opening an issue with the Node.js project to report the zlib memory leak, as it may be a bug that needs to be fixed.
  • If downgrading Node.js is not feasible, consider implementing a workaround, such as periodically restarting the application to prevent memory exhaustion.

Example

No code snippet is provided as the issue is related to a potential bug in the Node.js zlib module.

Notes

  • The issue may be specific to the combination of Node.js version and the next start command.
  • Downgrading Node.js may have other implications, such as potential security vulnerabilities or missing features.

Recommendation

  • Apply workaround: Downgrade to Node.js version 22.22.0, as it has been tested and does not exhibit the zlib memory leak issue. This is a temporary solution until the issue is fixed in a later Node.js version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING