cockatiel
cockatiel copied to clipboard
Custom abort signals throw TaskCancelledException without "reason"
First of all, great library, thank you for your contribution.
However, I've noticed a situation that I believe is a bug.
Custom abort signals throw the TaskCanceledException
and do not show any reason even when one has been assigned.
Please see the following example:
https://codesandbox.io/p/sandbox/cnd5xw
I have two buttons, one that starts the retries execution and another that cancels said execution.
When adding a custom abort signal to "execute" like this:
result = await wrap(timeoutPolicy, retryPolicy).execute( () => slowTask(20000), abortController.signal );
And then aborting it with a reason (from the button):
abortController.abort(canceledWithButtonReason);
The exception is TaskCanceledException
with the message Operation timed out after 20000ms
when this is not true. The execution was canceled because the user wanted it to via the button, the timeout had not yet expired.
Additionally, the provided reason
("Canceled from button") is not returned in the exception (it is undefined
there).
I am using aggressive timeouts, and the "onTimeOut" callback is also triggered in this case, which I also believe is an error.
In Cooperative timeouts this is even worse, no exception is throwed when I abort my custom signal.