fix(op_crate/fetch): infinite loop on fill headers (#10406)

Fixes a pesky bug in the fetch implementation where if the init part is
specified in `fetch` instead of the `Request` constructor, the
fillHeaders function receives two references to the same object, causing
it to append to the same list being iterated over.
This commit is contained in:
William Perron 2021-04-29 13:56:59 -04:00 committed by GitHub
parent 0ac2a17a0f
commit a50dab683f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View file

@ -247,11 +247,14 @@
// 31.
if (Object.keys(init).length > 0) {
let headers = headerListFromHeaders(this[_headers]);
let headers = headerListFromHeaders(this[_headers]).slice(
0,
headerListFromHeaders(this[_headers]).length,
);
if (init.headers !== undefined) {
headers = init.headers;
}
headerListFromHeaders(this[_headers]).slice(
headerListFromHeaders(this[_headers]).splice(
0,
headerListFromHeaders(this[_headers]).length,
);