Skip to content

stale-while-revalidate causing memory leak with cache interceptor #4208

@olessavluk

Description

@olessavluk

Reproducible By

node --expose-gc --inspect stale-while-revalidate.mjs
https://gist.github.com/olessavluk/8bdfb495c2b48c3baaab3dd704f85403

Logs & Screenshots

Example output
{
  rss: 107.09375,
  heapTotal: 72.96875,
  heapUsed: 37.90514373779297,
  external: 3.2410106658935547,
  arrayBuffers: 0.1122894287109375
}
Runnig 100 request sequentially
{
  rss: 2600.625,
  heapTotal: 2205.65625,
  heapUsed: 2170.1848220825195,
  external: 281.41249084472656,
  arrayBuffers: 231.66439628601074
}
Runnig 100 request sequentially
{
  rss: 2736.78125,
  heapTotal: 2044.453125,
  heapUsed: 2008.7924270629883,
  external: 512.9489650726318,
  arrayBuffers: 486.3542881011963
}
Sleeping for 2s to trigger GC
{
  rss: 2737.296875,
  heapTotal: 75.09375,
  heapUsed: 40.322914123535156,
  external: 466.6343173980713,
  arrayBuffers: 463.193058013916
}
^ see how much `external` & `arrayBuffers` increased with each run?

Environment

node v20.18.0
undici 7.9.0
uname -a: ... 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6000 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions