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:
1 parent
18059e50fa
commit
4061bfb3fe
9 files changed
+97
-53
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user