Response with 500 status code is very slow #482

Closed
opened 2025-12-29 08:28:53 +01:00 by adam · 3 comments
Owner

Originally created by @HappyRashair on GitHub (Jan 17, 2023).

Originally assigned to: @StefH on GitHub.

Describe the bug

Response with 500 response is significantly slower than corresponding 400 response

Expected behavior:

Performance should be roughly the same

Test to reproduce

 var accountGuid = Guid.NewGuid();
// 400ms
 server
            .Given(Request.Create()
                .WithPath($"/api/v2/carriers/{accountGuid}")
                .UsingPost())
            .RespondWith(
                Response.Create()
                    .WithStatusCode(400)
                    .WithBody("123")
                    .WithHeader("Content-Type", "text/plain")
            );
// 4 sec
 server
            .Given(Request.Create()
                .WithPath($"/api/v2/carriers/{accountGuid}")
                .UsingPost())
            .RespondWith(
                Response.Create()
                    .WithStatusCode(500)
                    .WithBody("123")
                    .WithHeader("Content-Type", "text/plain")
            );

.NET: Core 3.1
.Xunit: 2.4.1,
WireMock.Net: 1.5.5

Originally created by @HappyRashair on GitHub (Jan 17, 2023). Originally assigned to: @StefH on GitHub. ### Describe the bug Response with `500` response is significantly slower than corresponding `400` response ### Expected behavior: Performance should be roughly the same ### Test to reproduce ``` c# var accountGuid = Guid.NewGuid(); // 400ms server .Given(Request.Create() .WithPath($"/api/v2/carriers/{accountGuid}") .UsingPost()) .RespondWith( Response.Create() .WithStatusCode(400) .WithBody("123") .WithHeader("Content-Type", "text/plain") ); // 4 sec server .Given(Request.Create() .WithPath($"/api/v2/carriers/{accountGuid}") .UsingPost()) .RespondWith( Response.Create() .WithStatusCode(500) .WithBody("123") .WithHeader("Content-Type", "text/plain") ); ``` ### Other related info .NET: Core 3.1 .Xunit: 2.4.1, WireMock.Net: 1.5.5
adam added the question label 2025-12-29 08:28:53 +01:00
adam closed this issue 2025-12-29 08:28:53 +01:00
Author
Owner

@StefH commented on GitHub (Feb 6, 2023):

@HappyRashair
I did add that example code to https://github.com/WireMock-Net/WireMock.Net/pull/882

And when calling WireMock.Net from postman, the response for 400 and 500 is quick.
image

So can you please double check your application?

@StefH commented on GitHub (Feb 6, 2023): @HappyRashair I did add that example code to https://github.com/WireMock-Net/WireMock.Net/pull/882 And when calling WireMock.Net from postman, the response for 400 and 500 is quick. ![image](https://user-images.githubusercontent.com/249938/217072056-7481661f-fa80-4b48-bd06-8d3bacff5c6d.png) So can you please double check your application?
Author
Owner

@HappyRashair commented on GitHub (Feb 7, 2023):

Behaviour in our code is not different whether it's 400 or 500.
I've tested it again and it makes a different with / without the guid as path - perhaps it's something with longer paths matching?
It's fast in postman as you noticed - the issue occurs when I run it in the IDE (Rider in my case)

@HappyRashair commented on GitHub (Feb 7, 2023): Behaviour in our code is not different whether it's 400 or 500. I've tested it again and it makes a different with / without the guid as path - perhaps it's something with longer paths matching? It's fast in postman as you noticed - the issue occurs when I run it in the IDE (Rider in my case)
Author
Owner

@StefH commented on GitHub (Feb 18, 2023):

I'm closing this issue because it's very difficult for me to reproduce. If you can reproduce it with an console-app or example project, please comment here or create a new issue.

@StefH commented on GitHub (Feb 18, 2023): I'm closing this issue because it's very difficult for me to reproduce. If you can reproduce it with an console-app or example project, please comment here or create a new issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#482