Skip to content

Support 204 no-content for node 18 #127

@tompuric

Description

@tompuric

In Node.js 18, an experimental global fetch API is available by default (https://nodejs.dev/en/blog/announcements/v18-release-announce#fetch-experimental). axios-fetch currently assumes node-fetch as the underlying fetch mechanism.

This has compatibility issues in Node v18's fetch implementation for handling of 204 no-content results.

Nodes fetch (backed by undici) expects a 204 response to have a nullable body, however axios-fetch returns an empty buffer, resulting in the following error

TypeError {
    message: 'Response constructor: Invalid response status code 204',
}

The expectation is that axios-fetch also returns a nullable body for 204 no-content responses.

The current workaround to this is to avoid utilising nodes fetch impl via --no-experimental-fetch or override our global references with node-fetch

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