You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Leaks in Node >=v19 when test is repeated enough times.
Additional context
⚠️ Not really sure whether this issue belongs here or on Jest's repo. But, I have a hunch that it belongs here given that we're experiencing memory spikes with Node >=v19 in production. Nevertheless, I've opened an issue there too.
If a test, which uses native fetch, is iterated enough times in Node >=v19, Jest's --detectLeaks will report a memory leak.
VoltrexKeyva
added
memory
Issues and PRs related to the memory management or memory footprint.
fetch
Issues and PRs related to the Fetch API
labels
May 9, 2023
EXPERIMENTAL FEATURE!
Your test suite is leaking memory. Please ensure all references are cleaned.
There is a number of things that can leak memory:
- Async operations that have not finished (e.g. fs.readFile).
- Timers not properly mocked (e.g. setInterval, setTimeout).
- Keeping references to the global scope.
at onResult (node_modules/@jest/core/build/TestScheduler.js:150:18)
at Array.map (<anonymous>)
Since that's a jest feature and I don't plan on investigating how it tracks that, you should either report it to jest (and have them circle back to us if it turns out it's a node issue) or demonstrate the leak without using third-party modules.
Version
Node >=v19
Steps to reproduce
enisdenjo/jest-fetch-leak
repoExpected behavior
Doesn't leak ever.
Actual behavior
Leaks in Node >=v19 when test is repeated enough times.
Additional context
If a test, which uses native
fetch
, is iterated enough times in Node >=v19, Jest's--detectLeaks
will report a memory leak.This behaviour does not happen on Node <=v18.
Please check the leak detector tests in the CI.
Environment
The text was updated successfully, but these errors were encountered: