-
Notifications
You must be signed in to change notification settings - Fork 367
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
feat(delay): Support AbortSignal to delay for improved cancellation #52
Conversation
@Hanna922 is attempting to deploy a commit to the Toss Team on Vercel. A member of the Team first needs to authorize it. |
}; | ||
|
||
signal?.addEventListener('abort', onAbort); | ||
signal?.addEventListener('abort', onAbort, { once: true }); |
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.
👍
As you mentioned, I think making a separate error file would be helpful. The error's // error/AbortError.ts
export class AbortError extends Error {
constructor (message: string = 'The operation was aborted') {
super(message);
this.name = 'AbortError';
}
} // function/delay.ts
import { AbortError } from '../../error/AbortError';
/* ... */
return reject(new AbortError()); |
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.
Thanks for your great contribution!
Hi👋🏻 I have added the functionality to support cancellation via AbortSignal to the
delay
, following thedebounce
.While working on this, I had a question: Would it be better to create and use a common
Error
file, Like in undici?Thank you.
Before
After