Skip to content

Commit

Permalink
fix: move clear timeout for fetch to finally
Browse files Browse the repository at this point in the history
  • Loading branch information
Meierschlumpf committed Jul 28, 2024
1 parent e0cffba commit 1a64ffd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/common/src/fetch-with-timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export const fetchWithTimeout = (...[url, requestInit]: Parameters<typeof fetch>
// 10 seconds timeout:
const timeoutId = setTimeout(() => controller.abort(), 10000);

return fetch(url, { signal: controller.signal, ...requestInit }).then((response) => {
return fetch(url, { signal: controller.signal, ...requestInit }).finally(() => {
clearTimeout(timeoutId);
return response;
});
};

0 comments on commit 1a64ffd

Please sign in to comment.