From 08552fc6b9a18c736b6fd3939d8e0b434f5b8302 Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Sun, 31 May 2020 22:13:53 +0200 Subject: fix(fetch): network error on multiple redirects (#5985) --- cli/js/web/fetch.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'cli/js/web/fetch.ts') diff --git a/cli/js/web/fetch.ts b/cli/js/web/fetch.ts index a56ebe772..2f01e7ad7 100644 --- a/cli/js/web/fetch.ts +++ b/cli/js/web/fetch.ts @@ -288,6 +288,7 @@ export async function fetch( } } + let responseInit: ResponseInit = {}; while (remRedirectCount) { const fetchResponse = await sendFetchReq(url, method, headers, body); @@ -314,7 +315,7 @@ export async function fetch( }, }); - let responseInit: ResponseInit = { + responseInit = { status: fetchResponse.status, statusText: fetchResponse.statusText, headers: fetchResponse.headers, @@ -374,6 +375,12 @@ export async function fetch( return response; } } - // Return a network error due to too many redirections - throw notImplemented(); + + responseData.set(responseInit, { + type: "error", + redirected: false, + url: "", + }); + + return new Response(null, responseInit); } -- cgit v1.2.3