Closed 1NieR closed 2 years ago
After some debugging, I've traced the root cause of this bug to the CancellationTokenSource
that is being used in the selections.
After waiting for the second selection to be canceled, the CancellationTokenSource
enters in a canceled state and the loop is repeated, then the message is modified to contain the first selection. Due to the state of CancellationTokenSource
, when the internal TaskCompletionSource
is created, the callback that gets registered for the CancellationToken
is immediately called, setting the result of the TaskCompletionSource
prematurely.
A way to solve this is to set the (eventual) canceled result before registering the callback. This means that if you pass a canceled CancellationToken
to a selection/paginator, they will be canceled immediately, which in my opinion it's bad design.
The correct way to reuse a message for a selection is to use the CancellationTokenSource
once, then create a new, fresh one.
I will not close this issue because this is technically a bug, and I will make some changes in the lib to throw a proper exception when using a canceled CancellationToken
.
Hi. I get this error all the time. Can you help me please.
code example: