diff --git a/web/src/lib/polyfills.ts b/web/src/lib/polyfills.ts index b5917b5c..621c9b2b 100644 --- a/web/src/lib/polyfills.ts +++ b/web/src/lib/polyfills.ts @@ -1 +1,2 @@ import "./polyfills/user-activation"; +import "./polyfills/abortsignal-timeout"; diff --git a/web/src/lib/polyfills/abortsignal-timeout.ts b/web/src/lib/polyfills/abortsignal-timeout.ts new file mode 100644 index 00000000..8d9b3c66 --- /dev/null +++ b/web/src/lib/polyfills/abortsignal-timeout.ts @@ -0,0 +1,10 @@ +import { browser } from "$app/environment"; + +if (browser && 'AbortSignal' in window && !window.AbortSignal.timeout) { + window.AbortSignal.timeout = (milliseconds: number) => { + const controller = new AbortController(); + setTimeout(() => controller.abort("timed out"), milliseconds); + + return controller.signal; + } +}