-
Notifications
You must be signed in to change notification settings - Fork 623
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
BREAKING(async): simplify deadline()
logic, remove DeadlineError
and improve errors
#5058
Conversation
I don't understand why we want to make this change. Currently the user can distinguish whether the promise is aborted by signal or aborted by deadline by catching the error. Now they can't do it. |
You can compare using |
Oh, this sounds nice.
Sounds a good idea. Can you update the doc examples and test case to demonstrate this? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5058 +/- ##
=======================================
Coverage 92.70% 92.70%
=======================================
Files 482 482
Lines 38713 38723 +10
Branches 5462 5457 -5
=======================================
+ Hits 35888 35898 +10
Misses 2770 2770
Partials 55 55 ☔ View full report in Codecov by Sentry. |
I've decided to revert the use of |
DeadlineError
and improve thrown/rejected errors
DeadlineError
and improve thrown/rejected errorsdeadline()
logic, remove DeadlineError
and improve thrown/rejected errors
deadline()
logic, remove DeadlineError
and improve thrown/rejected errorsdeadline()
logic, remove DeadlineError
and improve errors
I've tweaked the direction of this PR and re-written the descript. @kt3k, please take a look once more. |
I think it's better to always just throw the reason itself, to be consistent with Web APIs like |
This code does, wrapped in a |
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Here the reason (which is usually already an |
Maybe |
Oh, I see. Thank you. I've made some adjustments, which made things even cleaner. PTAL. |
if (signal.aborted) { | ||
return Promise.reject(createAbortError(signal.reason)); | ||
} | ||
if (signal.aborted) return Promise.reject(signal.reason); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 2nd thought. Maybe this should throw. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I think the removal of wrapping of abort reason is a good move towards Web standard alignment. Thanks @0f-0b for the ideas!
What's changed
This PR:
@std/async
APIs areDOMException
s, with the appropriateAbortError
orTimeoutError
error names.deadline()
by relying onabortable()
.DeadlineError
fordeadline()
, as it's no longer needed.AbortSignal
is already aborted.Why was this change been made?
These changes were made to:
DeadlineError
.Migration guide
If using
deadline()
compare the error withDOMException
instead ofDeadlineError
when handling errors.Related
Depends on denoland/deno#23842