Ky: Edge <= 18 Invalid argument exception

Created on 19 Jun 2020  路  9Comments  路  Source: sindresorhus/ky

Pre-Chromium Microsoft Edge blows up when undefined is passed as an argument to the window.Headers constructor. As such, ky blows up when trying to make a request due to these lines.

bug

Most helpful comment

Fwiw, we used patch-package and added a nullish coalescing operator to handle the undefined case and it's been working so far. Though, we aren't using any of the more advanced features.

// we changed this
const result = new globals.Headers(source1);
// to this
const result = new globals.Headers(source1 ?? {});

Though, to provide better support when using it without transpiling, I believe a simple || would work as well.

All 9 comments

Thanks for the quick response. Would you be open to a pull request to patch it for Edge?

Does it work if you pass null? Personally, I'm fine with adding a simple ternary. But yeah, earlier versions of Edge may have other problems too, as they are unsupported.

Nope, it blows up with null the same as it does with undefined. Chromium and Firefox blow up with null as well (they work fine when passed undefined, however).

Fwiw, we used patch-package and added a nullish coalescing operator to handle the undefined case and it's been working so far. Though, we aren't using any of the more advanced features.

// we changed this
const result = new globals.Headers(source1);
// to this
const result = new globals.Headers(source1 ?? {});

Though, to provide better support when using it without transpiling, I believe a simple || would work as well.

Chrome version 49 has the same problem

This hit us the hard way...

@belgattitude if you need a quick fix till there's a release with this fix in it, we've had good luck using patch-package since it's such a small change.

Thanks ! I did a separate release (https://github.com/sindresorhus/ky/pull/264#issuecomment-652431596)... But good to know about patch-package I'll use it for sure

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacob-fueled picture jacob-fueled  路  3Comments

luxferresum picture luxferresum  路  7Comments

sindresorhus picture sindresorhus  路  7Comments

fruitraccoon picture fruitraccoon  路  4Comments

szmarczak picture szmarczak  路  5Comments