Skip to content

Fetch documentation misleading on Node/Undici GC quirks #8047

@halovanic

Description

@halovanic

Affected URL

https://nodejs.org/en/learn/getting-started/fetch

Describe the issue in detail:

The documentation and examples for getting started with Fetch on Node.js do not make clear the current spec-breaking behavior of Undici to require consumption of the response body.

The first two examples provided on the Fetch page always consume the body, the third actually appears to leak references if the response code indicates a failure due to the body not being consumed and an error being thrown instead.

While the Undici documentation explaning this behavior is currently linked to from the Fetch article, this aspect is buried very far down on that page, and the explanations there are oriented only around situations like trying to just consume headers, not basic error handling like here as presented both in the main Node documentation and in the majority of general Fetch documentation.

The fact that the example given appears to make this same mistake, as well as such leaks being definitely reproducible and surprising to many with similar code (myself included) under the latest LTS v22, would indicate to me this likely warrants at least a brief, dedicated explanation within the same page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    contentIssues/pr concerning contentlearnIssues/pr concerning the learn section

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions