From c538cfeaaa98e42af97f9dab0809437a1a265f49 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 16 Oct 2023 21:35:56 +0800 Subject: [PATCH] Add AbortSignal.timeout polyfill --- src/main.jsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.jsx b/src/main.jsx index e7eec379..9c21e63f 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -11,6 +11,19 @@ if (import.meta.env.DEV) { import('preact/debug'); } +// AbortSignal.timeout polyfill +// Temporary fix from https://github.com/mo/abortcontroller-polyfill/issues/73#issuecomment-1541180943 +// Incorrect implementation, but should be good enough for now +if ('AbortSignal' in window) { + AbortSignal.timeout = + AbortSignal.timeout || + ((duration) => { + const controller = new AbortController(); + setTimeout(() => controller.abort(), duration); + return controller.signal; + }); +} + render(