Polly-Samples
Polly-Samples copied to clipboard
Async demo 09: Never stops after running 14+ requests
After running the demo a few times and allowing it to run for several request, 14+ times), the screen fills up with
Object name: 'System.Net.Http.HttpClient'.
The exception happens on line 159.
Looks like when the loop ends by the CancellationToken being fired and the HttpClient is disposed of:
https://github.com/App-vNext/Polly-Samples/blob/88c3b8e8373bdefcf8012f1c09325f6de5ba2db0/PollyDemos/Async/AsyncDemo09_Wrap-Fallback-Timeout-WaitAndRetry.cs#L144
If there are any cancelled HTTP requests still pending to run, they'll try to use the now-disposed HttpClient, causing an ObjectDisposedException:
https://github.com/App-vNext/Polly-Samples/blob/88c3b8e8373bdefcf8012f1c09325f6de5ba2db0/PollyDemos/Async/AsyncDemo09_Wrap-Fallback-Timeout-WaitAndRetry.cs#L159
Yes, that is correct.
However, the policy is configured to handle all exceptions and to run forever, and the policyWrap.ExecuteAsync() is accepting a cancellationToken but which appears not to be honoring.
Also, how would I write something like, handle all exceptions except for MyException? Something like:
Policy.Handle<Exception>().ButNot<MyException>()...
Thanks.
@peter-csala Something to consider when you get to migrating this demo.
@martincostello Please assign to me, otherwise I will forget it :)
After the V8 migration I can not reproduce the problem. The application can be stopped any time.
@martincostello I think we can close this issue if you agree.