fix #2438 make sure each async part of HttpConnection is abortable #2440
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Everything old is new again, some lessons have to be learned over and over 😢
In NEST
0.xand1.xthe HttpConnection async bits is implemented using a marvalous APM callback soup implementation which was hard to read but battle hardened.With
2.xwe finally took the plunge to a TAP and async/await based implementation which is a joy to read. However in doing so we did not port all the timeouts registered with the threadpool to make the unabortable bits such asGetRequestStreamAsyncandGetResponseAsync.This PR brings back some APM wrapped to a Task with
Task.Factory.FromAsyncandThreadPool.RegisterWaitForSingleObjectis back in action to guard these calls.To test this works start an
5.xelasticsearch server and use the AutoResponder in fiddler and set up the following rules:Then using
First using the latest
rc3you'll see the synchronous code path adheres the timeout but the async code path does not.If you then add manual references to a build from this branch you'll see both behaving fine.
If you uncheck the delay rule in fiddler you'll see both request succeeding again with no timeouts.