fix: refactor i18n loadTranslations and set timeout to 3s (#22878)

* refactor

* use abort controller

* address comment

* fix tests

* fix time

* fix tests

* fix platform library build
This commit is contained in:
Benny Joo authored and GitHub committed 2025-08-04 10:30:18 +01:00
1 parent 18059e50fa
commit 4061bfb3fe
9 files changed
+97 -53

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
export async function fetchWithTimeout(url: string, options: RequestInit = {}, timeoutMs: number) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), timeoutMs);
try {
const response = await fetch(url, {
...options,
signal: controller.signal,
});
return response;
} finally {
clearTimeout(timeout);
}
}