-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: When headers is native Headers object, they won't get send #860
Comments
I came across the problem, too. Before I saw this Issue, it took a few debugging sessions stepping through the code to discover that, indeed, the Attempting to use an Array doesn't work neither because What worked was to alias polyfill's
...and use Hope this helps. |
Resolved via #1358 |
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 builtinHeaders
object, the instanceof check will fail, as well as the fallback case becausegetOwnPropertyNames()
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.The text was updated successfully, but these errors were encountered: