Skip to content

Bug: When headers is native Headers object, they won't get send #860

@FokkeZB

Description

@FokkeZB

Steps to Reproduce

Code: https://codesandbox.io/s/determined-cdn-7k3gx?file=/src/index.js
App: https://7k3gx.csb.app/

Theories

We do new Headers(options.headers):

https://github.com/github/fetch/blob/75d9455d380f365701151f3ac85c5bda4bbbde76/fetch.js#L367-L369

Which will use the local polyfill function Headers which is also what this line will check against:

https://github.com/github/fetch/blob/75d9455d380f365701151f3ac85c5bda4bbbde76/fetch.js#L86-L90

But if options.headers is the builtin Headers object, the instanceof check will fail, as well as the fallback case because getOwnPropertyNames() will return an empty object:

https://github.com/github/fetch/blob/75d9455d380f365701151f3ac85c5bda4bbbde76/fetch.js#L94-L98

Solution

Don't polyfill Headers when there's a builtin, native version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions