fix(app): load on browsers without AbortSignal.any (#3439)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-13 00:28:09 +02:00
1 parent c7da0cf33d
commit 3b35db2681
2 files changed
+33

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
function abortSignalTimeout(milliseconds: number): AbortSignal {
const controller = new AbortController();
setTimeout(() => controller.abort(new DOMException('The operation timed out.', 'TimeoutError')), milliseconds);
return controller.signal;
}
function abortSignalAny(signals: Iterable<AbortSignal>): AbortSignal {
const controller = new AbortController();
const sources = [...signals];
const aborted = sources.find((source) => source.aborted);
if (aborted) {
controller.abort(aborted.reason);
return controller.signal;
}
for (const source of sources) {
source.addEventListener('abort', () => controller.abort(source.reason), {once: true, signal: controller.signal});
}
return controller.signal;
}
export function installAbortSignalPolyfill(target: typeof AbortSignal = AbortSignal): void {
if (typeof target.timeout !== 'function') {
target.timeout = abortSignalTimeout;
}
if (typeof target.any !== 'function') {
target.any = abortSignalAny;
}
}
installAbortSignalPolyfill();
+1
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later // SPDX-License-Identifier: AGPL-3.0-or-later
import '@app/app/AbortSignalPolyfill';
import '@app/app/BootShell.css'; import '@app/app/BootShell.css';
import {startAppStorage} from '@app/features/platform/state/AppStorageBootstrap'; import {startAppStorage} from '@app/features/platform/state/AppStorageBootstrap';
import {installBrowserStorageAccessProtection} from '@app/features/platform/state/ProtectedWebStorage'; import {installBrowserStorageAccessProtection} from '@app/features/platform/state/ProtectedWebStorage';