Skip to content

AbortHandler's timeout should always be cleared #474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/fetcher/url_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ async function get(url, options) {
...options,
signal: controller.signal,
credentials: options.withCredentials ? 'include' : 'omit',
})
.finally(()=>{
clearTimeout(timer);
Comment on lines +70 to +71
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done in a finally block after the catch ? since .finally() is usually used in a Promise chain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the await isn't that different that a promise chain, only different syntax. if you would want to move it to the try..catch..finally. the const timer needs to be moved outside the try block since it's block scoped. probably all together less neat.

});
clearTimeout(timer);

const error = handleError(response);
if (error) {
Expand Down