-
Notifications
You must be signed in to change notification settings - Fork 403
#375 Response stream corruption when a request is cancelled #394
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
Conversation
|
I want to use this package, but I need this fix for it to work. Can this PR be merged? |
galvesribeiro
left a comment
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.
LGTM
|
@jterry75 any thoughts? |
|
@Duracell1989 did you experience this problem of stream not having <CR/LF> and execution being trapped there? |
No, the problem was that when cancelling; it would throw |
|
@jterry75; Rebased with the latest master- thus, resolved all the merge conflicts. |
|
@Duracell1989 - Super sorry I thought that #481 fixed this but now I looked back and realized we only fixed one of the three similar methods. Given the change we did there by removing the |
|
I wouldn't recommend WithCancellation extension, produces different results depending on docker response time, causing tests to fail on CI/CD pipeline tests.
I know I pushed it, didn't know better then
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Justin <notifications@github.com>
Sent: Tuesday, February 2, 2021 5:57:36 PM
To: dotnet/Docker.DotNet <Docker.DotNet@noreply.github.com>
Cc: David García Vives <david.garcia.vives@hotmail.com>; Comment <comment@noreply.github.com>
Subject: Re: [dotnet/Docker.DotNet] #375 Response stream corruption when a request is cancelled (#394)
@Duracell1989<https://github.com/Duracell1989> - Super sorry I thought that #481<#481> fixed this but now I looked back and realized we only fixed one of the three similar methods. Given the change we did there by removing the stream.Dispose on task cancellation we no longer should ever see the ObjectDisposedException. I think you want to follow the pattern for the WithCancellation we did in the other one on the ReadLineAsync() call to unblock the task right?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#394 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ARATUN5AIKYGYUSNCTRM3HTS5AVIBANCNFSM4HNNFE6Q>.
|
|
As suggested by @dgvives: I removed the WithCancellation and have rewritten this to the same cancellation as the rest of the code. |
|
@Duracell1989 apologies, I didn't explain myself properly
Commit d7372c0 didn't pass the tests, being cancelled after 360m build timeout on the CI/CD pipeline. That I have in mind is to replace After some unexpected results, I just updated this part avoid exceptions from uncertain execution frames. internal static async Task MonitorStreamForMessagesAsync<T>(Task<Stream> streamTask, CancellationToken cancel, IProgress<T> progress)
{
var tcs = new TaskCompletionSource<bool>();
using (cancel.Register(() => tcs.TrySetCanceled(cancel)))
using (var stream = await streamTask)
using (var reader = new StreamReader(stream, new UTF8Encoding(false)))
using (var jsonReader = new JsonTextReader(reader) { SupportMultipleContent = true })
{
while (await await Task.WhenAny(jsonReader.ReadAsync(default), tcs.Task))
{
var ev = Serializer.Deserialize<T>(jsonReader);
progress.Report(ev);
}
}
}Haven't pushed this yet as it is pending tests. |
|
@dgvives; you're going to add my |
|
@Duracell1989 I won't add your changes to the branch I'm currently working on, I had to learn it is considered bad contributor etiquette. Besides this it would be nice to include some test case that calls the modified method. You decide to go ahead with tests and like to see any example, I'm happy to help, just ping me. |
|
@Duracell1989 by looking at your modification for Have you tested |
|
@dgvives I didn't test that specific change - also because I found it a challenge. Let me revert that one in that function. |
|
@Duracell1989 I closed #487, tests results were not the same on all executions. |
|
@dgvives; Yeah, I know how to run tests. But if I run all the tests; there is this 1 tests that fail. But if you run that failing test on it's own. If passed. So, some data isn't getting cleared between multiple tests. |
|
I think we have a race-condition failure: |
Added a wait to the MonitorEventsAsync_Succeeds test to have some progress messages.
|
I've had the same problem while trying to validate issues were solved. I ran into the same problems you faced, different test results on different executions for the same tests, tests running fine locally but failing on CI/CD pipeline, tests running ok individually but failing when all together, tests never ending and causing TimeoutException on build agent. |
|
I've fixed this by adding the |
|
@Duracell1989 / @dgvives - Which of these changes are we taking looks like both are still being actively worked on? |
|
These changes were merged into #487 and it continued from there until tests success |
|
Sounds good can we close this one? |
|
Best practice is to merge a PR if it adds value. Waiting for another PR which could improve more, isn't great, because you never know when this other PR will be approved (or never at all). In this case; the #487 has been closed and no timeline is present when other improvements will be finished. |
|
@Duracell1989 / @dgvives - The other was closed are we wanting to take this one first and work out the rest later? |
|
@jterry75 I hit a wall being unable to cancel There is a reason behind calling Stream.Dispose(), once The stream is continuous and there is no way to stop reading because the reader is using calls to I'm reviewing implementation on source code for these methods, but it's taking a while. I can't recommend removing |
|
From what I understand: |
|
@Duracell1989 - The |
|
Found the problem Basically, deep inside it goes inside a Detailed explanation here #487 (comment) |
I've ran into the same issue as #375; this code works in my project.
No more
IOExceptions after cancelling the token.