Skip to content

Commit b4d456d

Browse files
committed
Improve abort detection in browsers
1 parent 03a0ee4 commit b4d456d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/client/Omaha.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ export class Omaha extends EventEmitter<OmahaEvents> {
289289
* @returns
290290
*/
291291
private async _fetchWithRetries<T>(method: string, path: string, body?: PostOptions, attempt = 0): Promise<T> {
292+
const controller = this._controller;
293+
292294
try {
293295
const response = await this._fetch<T>(method, path, body);
294296

@@ -304,8 +306,8 @@ export class Omaha extends EventEmitter<OmahaEvents> {
304306
this.emit('server_error', error);
305307
throw error;
306308
}
307-
else if (error instanceof Error || (DOMException && error instanceof DOMException)) {
308-
if (error.name === 'AbortError') {
309+
else if (error instanceof Error || (typeof DOMException !== 'undefined' && error instanceof DOMException)) {
310+
if (controller !== this._controller || error.name === 'AbortError' || error.message.endsWith('The user aborted a request.')) {
309311
throw new AbortError('The operation was aborted.');
310312
}
311313

0 commit comments

Comments
 (0)