Repository navigation
From Feedback in issue 2149, Propagate CancellationToken in calls to TrySetCanceled: - #2608
Conversation
|
You should add a new test for this. You can add one in the FunctionalTests and either use a MockHandler or connect to the same server as the other functional test. See this StackOverflow issue which reports a similar bug in .NET Framework (Desktop). It has repro code which could be re-purposed as your test case. |
There was a problem hiding this comment.
You need to leave this as true
There was a problem hiding this comment.
Thanks for pointing out that bug. A few remarks:
1.- I tried it , modifying it so the constructor of HttpClient receives a WinHttpHandler and touches the modified code. I could repro the results without my changes.
2.- After adding my changes the bug is still there, the property IsCancellationRequested doesn't seem to propagate to the cancellation token of the exception being thrown. I'm still investigating why and what part of the stack is actually in charge of throwing that exception.
3.- I know that my modified code is being touched because if I throw an exception just before calling TrySetCanceled I can see it. So I'm thinking of what other test could be helpful to verify this.
There was a problem hiding this comment.
@davidsh When you say to leave "locked" as true, do you mean for every project.lock.json or only for the one in System.Runtime.Extensions?
There was a problem hiding this comment.
@josguil My comment was about your change in this PR. You were changing the locked field from 'true' to 'false'. You need to leave it as 'true'. In general, once the project.lock.json file is made, the lock field should be set to 'true'.
If you look at other project.lock.json files in the CoreFx repo, you'll see that the locked field is set to 'true'.
|
Reference issue #2165 |
There was a problem hiding this comment.
There's a call to TrySetCanceled inside of the Register callback a few lines below this; presumably that should be updated as well, e.g.:
var cancellationTokenRegistration = state.CancellationToken.Register(s =>
{
RequestState rs = (RequestState)s;
rs.Tcs.TrySetCanceled(rs.CancellationToken);
}, state);?
There was a problem hiding this comment.
Thanks for pointing that out. I'll investigate if the change is needed also there.
88c4408 to
fb83f00
Compare
|
@CIPop @davidsh @SidharthNabar I did a new iteration, with tests added. |
There was a problem hiding this comment.
@josguil I think we should have a larger discussion regarding configuration file locations and how these can be changed by the users to allow them to exercise the code against their own local servers.
There was a problem hiding this comment.
Yeah, I agree. Issue related is https://github.com/dotnet/corefx/issues/2383.
|
LGTM |
|
LGTM once the build goes GREEN. |
|
There's a test failure: |
|
The failed test Is not in the HTTP libraries:
|
|
@dotnet-bot test this please |
…ts to verify it. Addressing Feedback in GitHub Renaming TestHandler to SendAsyncWinHttpMockHandler and adding missing spaces. Added missing line in json file to use System.Runtime.InteropServices.RuntimeInformation.
69fc88c to
e76774d
Compare
…2149 From Feedback in issue 2149, Propagate CancellationToken in calls to TrySetCanceled:
As a minor improvement, using the new TrySetCanceled overload, you could make this state.Tcs.TrySetCanceled(state.CancellationToken) ...
that just helps to ensure that the token is propagated to anyone getting an OperationCanceledException later on.