Skip to content

Fix memory leak in Fetch with large stream responses #1870

@2400030206

Description

@2400030206

What is the issue with the Fetch Standard?

Memory leak in Fetch with large stream responses

Description

When processing large responses as ReadableStreams, some implementations fail to properly garbage collect stream resources, leading to memory leaks.

Steps to Reproduce

  1. Fetch a large resource (100MB+) as a stream
  2. Cancel the stream before complete consumption
  3. Repeat multiple times
  4. Observe memory usage growth

Expected Behavior

Memory should be properly reclaimed when streams are cancelled or consumed.

Actual Behavior

Memory usage grows with each stream cancellation and is not reclaimed.

Browser Affected

  • Chrome: ✅ No leak detected
  • Firefox: ❌ Memory grows with each cancelled stream
  • Safari: ⚠️ Minor memory accumulation

Specification Reference

https://fetch.spec.whatwg.org/#body-mixin

Severity

Medium - Affects long-running web applications with frequent large data transfers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions