Skip to content

Memory leak with fetch on Node v19+ when using Jest's --detectLeaks #47936

@enisdenjo

Description

@enisdenjo

Version

Node >=v19

Steps to reproduce

  1. Clone enisdenjo/jest-fetch-leak repo
  2. Read its readme for local repro
  3. Check out the GitHub Actions for CI repo

Expected behavior

Doesn't leak ever.

Actual behavior

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.

This behaviour does not happen on Node <=v18.

Please check the leak detector tests in the CI.

Environment

ubuntu-latest from GitHub Actions

Metadata

Metadata

Assignees

No one assigned

    Labels

    fetchIssues and PRs related to the Fetch APImemoryIssues and PRs related to the memory management or memory footprint.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions