Inconsistent result with overlapping (duplicate) request #472

Closed
opened 2025-12-29 15:24:40 +01:00 by adam · 2 comments
Owner

Originally created by @Morshed11218 on GitHub (Dec 3, 2022).

Originally assigned to: @StefH on GitHub.

Hi,
I'm experiencing inconsistent result when it comes to overlapping (duplicate) request. In the WireMock documentation, it states that for a overlapping request, the most recent mock will be returned but I'm not seeing that behavior. What I'm seeing is that the response will sometimes be the first mock or the most recent mock.

Here is the sample code:


            for(var i = 0; i < 20; i++)
            {
                var server = WireMockServer.Start();

                server
                  .Given(
                    Request.Create().WithPath("/some/thing").UsingGet()
                  )
                  .RespondWith(
                    Response.Create()
                      .WithStatusCode(200)
                      .WithHeader("Content-Type", "text/plain")
                      .WithBody("Hello world!")
                  );

                server
                  .Given(
                    Request.Create().WithPath("/some/thing").UsingGet()
                  )
                  .RespondWith(
                    Response.Create()
                      .WithStatusCode(200)
                      .WithHeader("Content-Type", "text/plain")
                      .WithBody("Hello world duplicate!")
                  );

                using (var client = new HttpClient())
                {
                    var response = await client.GetAsync($"{server.Url}/some/thing");
                    var content = await response.Content.ReadAsStringAsync();
                    Console.WriteLine($"counter {i} value:{content}");
                }

                server.Reset();
                server.Dispose();
                server.Stop();
            }

I'm expecting 'Hello world duplicate!' all the time but I sometime get 'Hello world!'

Result:

counter 0 value:Hello world!
counter 1 value:Hello world duplicate!
counter 2 value:Hello world!
counter 3 value:Hello world duplicate!
counter 4 value:Hello world!
counter 5 value:Hello world!
counter 6 value:Hello world duplicate!
counter 7 value:Hello world!
counter 8 value:Hello world duplicate!
counter 9 value:Hello world!
counter 10 value:Hello world!
counter 11 value:Hello world!
counter 12 value:Hello world duplicate!
counter 13 value:Hello world!
counter 14 value:Hello world duplicate!
counter 15 value:Hello world duplicate!
counter 16 value:Hello world duplicate!
counter 17 value:Hello world duplicate!
counter 18 value:Hello world!
counter 19 value:Hello world!

Originally created by @Morshed11218 on GitHub (Dec 3, 2022). Originally assigned to: @StefH on GitHub. Hi, I'm experiencing inconsistent result when it comes to overlapping (duplicate) request. In the WireMock documentation, it states that for a overlapping request, the most recent mock will be returned but I'm not seeing that behavior. What I'm seeing is that the response will sometimes be the first mock or the most recent mock. Here is the sample code: ``` c# for(var i = 0; i < 20; i++) { var server = WireMockServer.Start(); server .Given( Request.Create().WithPath("/some/thing").UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "text/plain") .WithBody("Hello world!") ); server .Given( Request.Create().WithPath("/some/thing").UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "text/plain") .WithBody("Hello world duplicate!") ); using (var client = new HttpClient()) { var response = await client.GetAsync($"{server.Url}/some/thing"); var content = await response.Content.ReadAsStringAsync(); Console.WriteLine($"counter {i} value:{content}"); } server.Reset(); server.Dispose(); server.Stop(); } ``` I'm expecting 'Hello world duplicate!' all the time but I sometime get 'Hello world!' **Result:** counter 0 value:Hello world! counter 1 value:Hello world duplicate! counter 2 value:Hello world! counter 3 value:Hello world duplicate! counter 4 value:Hello world! counter 5 value:Hello world! counter 6 value:Hello world duplicate! counter 7 value:Hello world! counter 8 value:Hello world duplicate! counter 9 value:Hello world! counter 10 value:Hello world! counter 11 value:Hello world! counter 12 value:Hello world duplicate! counter 13 value:Hello world! counter 14 value:Hello world duplicate! counter 15 value:Hello world duplicate! counter 16 value:Hello world duplicate! counter 17 value:Hello world duplicate! counter 18 value:Hello world! counter 19 value:Hello world!
adam added the bug label 2025-12-29 15:24:40 +01:00
adam closed this issue 2025-12-29 15:24:40 +01:00
Author
Owner

@StefH commented on GitHub (Dec 4, 2022):

@Morshed11218
This is indeed wrong. I did fix it.

Can you test a preview version "1.5.12-ci-16783" ?

(https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)

@StefH commented on GitHub (Dec 4, 2022): @Morshed11218 This is indeed wrong. I did fix it. Can you test a preview version "1.5.12-ci-16783" ? (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)
Author
Owner

@Morshed11218 commented on GitHub (Dec 5, 2022):

@StefH
It's working with build "1.5.12-ci-16783". Thanks for the quick fix.

@Morshed11218 commented on GitHub (Dec 5, 2022): @StefH It's working with build "1.5.12-ci-16783". Thanks for the quick fix.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#472