Skip to content

Commit

Permalink
Fix polyfill
Browse files Browse the repository at this point in the history
Signed-off-by: Sri Krishna Paritala <skrishna@buf.build>
  • Loading branch information
srikrsna-buf committed Sep 5, 2024
1 parent adffc7c commit 87cf10f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/connect-web/browserstack/karma-fixup-AbortController.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@
// a simplistic polyfill for AbortController and AbortSignal

(function () {
if (globalThis.AbortController && globalThis.AbortSignal) {
if (!globalThis.AbortController || !globalThis.AbortSignal) {
// `throwIfAborted` was added much later.
if (!globalThis.AbortSignal.prototype.throwIfAborted) {
globalThis.AbortSignal.prototype.throwIfAborted = function () {
if (this.aborted) {
const err = new Error("operation aborted");
err.name = "AbortError";
throw err;
}
};
}
return;
}

Expand Down

0 comments on commit 87cf10f

Please sign in to comment.