Skip to content

Revert "feat: fetch with keepalive (#618)" #651

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

Merged
merged 1 commit into from
Apr 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 26 additions & 27 deletions src/dispatch/FetchHttpHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,38 +88,37 @@ export class FetchHttpHandler implements HttpHandler {

const fetchRequest = new Request(url, requestOptions);
const raceOfPromises = [
this.fetchFunction!.apply(window, [
fetchRequest,
{ keepalive: true }
]).then((response) => {
const fetchHeaders: any = response.headers;
const transformedHeaders: HeaderBag = {};

for (const pair of fetchHeaders.entries() as string[][]) {
transformedHeaders[pair[0]] = pair[1];
}

const hasReadableStream = response.body !== undefined;

// Return the response with buffered body
if (!hasReadableStream) {
return response.blob().then((body) => ({
this.fetchFunction!.apply(window, [fetchRequest]).then(
(response) => {
const fetchHeaders: any = response.headers;
const transformedHeaders: HeaderBag = {};

for (const pair of fetchHeaders.entries() as string[][]) {
transformedHeaders[pair[0]] = pair[1];
}

const hasReadableStream = response.body !== undefined;

// Return the response with buffered body
if (!hasReadableStream) {
return response.blob().then((body) => ({
response: new HttpResponse({
headers: transformedHeaders,
statusCode: response.status,
body
})
}));
}
// Return the response with streaming body
return {
response: new HttpResponse({
headers: transformedHeaders,
statusCode: response.status,
body
body: response.body
})
}));
};
}
// Return the response with streaming body
return {
response: new HttpResponse({
headers: transformedHeaders,
statusCode: response.status,
body: response.body
})
};
}),
),
requestTimeout(requestTimeoutInMs)
];
if (abortSignal) {
Expand Down