Skip to content

Commit

Permalink
Merge pull request #15343 from Snuffleupagus/AbortController-uncondit…
Browse files Browse the repository at this point in the history
…ional

Use `AbortController` unconditionally with the Fetch API
  • Loading branch information
timvandermeij authored Aug 27, 2022
2 parents cb8d56f + b0a73a9 commit a1cc923
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/display/fetch_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function createFetchOptions(headers, withCredentials, abortController) {
return {
method: "GET",
headers,
signal: abortController?.signal,
signal: abortController.signal,
mode: "cors",
credentials: withCredentials ? "include" : "same-origin",
redirect: "follow",
Expand Down Expand Up @@ -114,9 +114,7 @@ class PDFFetchStreamReader {
this._disableRange = true;
}

if (typeof AbortController !== "undefined") {
this._abortController = new AbortController();
}
this._abortController = new AbortController();
this._isStreamingSupported = !source.disableStream;
this._isRangeSupported = !source.disableRange;

Expand Down Expand Up @@ -207,9 +205,7 @@ class PDFFetchStreamReader {
if (this._reader) {
this._reader.cancel(reason);
}
if (this._abortController) {
this._abortController.abort();
}
this._abortController.abort();
}
}

Expand All @@ -224,10 +220,7 @@ class PDFFetchStreamRangeReader {
this._readCapability = createPromiseCapability();
this._isStreamingSupported = !source.disableStream;

if (typeof AbortController !== "undefined") {
this._abortController = new AbortController();
}

this._abortController = new AbortController();
this._headers = createHeaders(this._stream.httpHeaders);
this._headers.append("Range", `bytes=${begin}-${end - 1}`);

Expand Down Expand Up @@ -274,9 +267,7 @@ class PDFFetchStreamRangeReader {
if (this._reader) {
this._reader.cancel(reason);
}
if (this._abortController) {
this._abortController.abort();
}
this._abortController.abort();
}
}

Expand Down

0 comments on commit a1cc923

Please sign in to comment.