1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Let leave requests outlive the window

This commit is contained in:
Robin Townsend
2022-10-26 17:50:20 -04:00
parent 13c751c060
commit dbdaa1540a
5 changed files with 35 additions and 5 deletions

View File

@@ -234,7 +234,7 @@ export class FetchHttpApi<O extends IHttpOpts> {
method: Method,
url: URL | string,
body?: Body,
opts: Pick<IRequestOpts, "headers" | "json" | "localTimeoutMs" | "abortSignal"> = {},
opts: Pick<IRequestOpts, "headers" | "json" | "localTimeoutMs" | "keepAlive" | "abortSignal"> = {},
): Promise<ResponseType<T, O>> {
const headers = Object.assign({}, opts.headers || {});
const json = opts.json ?? true;
@@ -252,6 +252,7 @@ export class FetchHttpApi<O extends IHttpOpts> {
}
const timeout = opts.localTimeoutMs ?? this.opts.localTimeoutMs;
const keepAlive = opts.keepAlive ?? false;
const signals = [
this.abortController.signal,
];
@@ -284,6 +285,7 @@ export class FetchHttpApi<O extends IHttpOpts> {
referrerPolicy: "no-referrer",
cache: "no-cache",
credentials: "omit", // we send credentials via headers
keepalive: keepAlive,
});
} catch (e) {
if ((<Error>e).name === "AbortError") {