Skip to content
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

Add to LogEntries before Task completed #831

Open
kelvin-a-law opened this issue Oct 17, 2022 · 1 comment
Open

Add to LogEntries before Task completed #831

kelvin-a-law opened this issue Oct 17, 2022 · 1 comment
Assignees
Labels

Comments

@kelvin-a-law
Copy link

kelvin-a-law commented Oct 17, 2022

Whilst testing timeout and retry policies I came across an issue where LogEntries were not updated before the test finished. Take this example, not exact code:

// handle 5**, 408,
// retry 3 times with a timeout per retry

var retryPolicy = HttpPolicyExtensions
    .HandleTransientHttpError()
    .Or<TimeoutRejectedException>()
    .RetryAsync(3);

var policy = retryPolicy.WrapAsync(
    HttpPolicy.TimeoutAsync(TimeSpan.FromMilliseconds(300)));

using var server = WireMockServer.Start();

server
    .Given(Request.Create().UsingGet())
    .RespondWith(Response.Create()
        .WithDelay(1000)
        .WithStatusCode(HttpStatusCode.InternalServerError));

var httpClient = CreateHttpClient(policy);

await Assert.ThrowsAsync<TimeoutRejectedException>(() => 
    httpClient.GetAsync(server.Url));

// wiremock leaves recording the requests till the end which means timeouts cause LogEntries to go missing. 
_testOutputHelper.WriteLine("Calls made: " + wireMockServer.LogEntries.Count());

The WithDelay(1000) will cause the policy to timeout (within 300ms), eventually throwing a TimeoutRejectedException, the test will end with a printed line of Calls made: 1 as the other calls are still processing.

Can we add the LogEntry as soon as the request has been received, update when match has been made, with null values for the response, then update it when a response has been created?

@StefH
Copy link
Collaborator

StefH commented Nov 7, 2022

@kelvin-a-law
This will require some advanced changes in the current logic, I need to think on that if this can be updated, or that';s too much work.

@StefH StefH self-assigned this Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants