Skip to content

Commit

Permalink
Remove silent abourt (#3436)
Browse files Browse the repository at this point in the history
  • Loading branch information
HarelM authored Dec 3, 2023
1 parent 3abe643 commit 0cec13c
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/util/ajax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export const makeRequest = function(requestParameters: RequestParameters, abortC
}
if (!isFileURL(requestParameters.url)) {
if (fetch && Request && AbortController && Object.prototype.hasOwnProperty.call(Request.prototype, 'signal')) {
return silenceOnAbort(makeFetchRequest(requestParameters, abortController), abortController);
return makeFetchRequest(requestParameters, abortController);
}
if (isWorker(self) && self.worker && self.worker.actor) {
return self.worker.actor.sendAsync({type: 'getResource', data: requestParameters, mustQueue: true, targetMapId: GLOBAL_DISPATCHER_ID}, abortController);
Expand All @@ -246,15 +246,6 @@ export const makeRequest = function(requestParameters: RequestParameters, abortC
return makeXMLHttpRequest(requestParameters, abortController);
};

// This needs to be removed in general, see #3308
function silenceOnAbort<T>(promise: Promise<T>, abortController: AbortController): Promise<T> {
return new Promise((resolve, reject) => {
promise
.then(result => { if (!abortController.signal.aborted) resolve(result); })
.catch(error => { if (!abortController.signal.aborted) reject(error); });
});
}

export const getJSON = <T>(requestParameters: RequestParameters, abortController: AbortController): Promise<{data: T} & ExpiryData> => {
return makeRequest(extend(requestParameters, {type: 'json'}), abortController);
};
Expand Down

0 comments on commit 0cec13c

Please sign in to comment.