A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: bound API request time with abort timeout (#10346)
Dvalin216911b2fa7028
diff --git a/packages/core/src/utils/http.ts b/packages/core/src/utils/http.tsindex 032a502d2..75b8a1721 100644--- a/packages/core/src/utils/http.ts+++ b/packages/core/src/utils/http.ts@@ -139,9 +139,11 @@ export function errorTransformer(errorJson: {};}-async function fetchWrapped(input: string, init: RequestInit) {+async function fetchWrapped(input: string, init: RequestInit, timeoutMs = 30000) {+ const controller = new AbortController();+ const timeout = setTimeout(() => controller.abort(), timeoutMs);try {- const response = await fetch(input, init);+ const response = await fetch(input, { ...init, signal: controller.signal });return response;} catch (e) {const host = extractHostname(input);@@ -154,6 +156,8 @@ async function fetchWrapped(input: string, init: RequestInit) {);throw e;+ } finally {+ clearTimeout(timeout);}}