Skip to content

Response.statusText should not default #578

@jaydenseric

Description

@jaydenseric

At the moment, node-fetch behavior regarding Response.statusText differs from the fetch specification and native browser implementations.

If the server does not respond with status text, node-fetch incorrectly sets a default message derived from the HTTP status code. I think that happens here:

https://github.com/bitinn/node-fetch/blob/v2.3.0/src/response.js#L34

In fact, for HTTP/2 connections the statusText should always be blank because HTTP/2 doesn't support it:

https://fetch.spec.whatwg.org/#concept-response-status-message

Why does this matter, other than spec compliance? If your server side rendered app displays a fetch error statusText that technically should not exist, you end up with the client render (and fetch) producing a correct result that's different:

node-fetch response statusText bug

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions