__admin/requests - "Collection was modified" exception #197

Closed
opened 2025-12-29 14:24:52 +01:00 by adam · 6 comments
Owner

Originally created by @gregoks on GitHub (Jul 31, 2019).

Originally assigned to: @StefH on GitHub.

Hi,

When I accesed /__admin/requests I got the following exception:

{"Status":"{"ClassName":"System.InvalidOperationException","Message":"Collection was modified; enumeration operation may not execute.","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":" at System.Collections.Generic.List1.Enumerator.MoveNextRare()\\r\\n at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)\r\n at WireMock.Server.FluentMockServer.ToJson[T](T result, Boolean keepNullValues)\r\n at WireMock.ResponseProviders.DynamicResponseProvider.ProvideResponseAsync(RequestMessage requestMessage, IFluentMockServerSettings settings)\r\n at WireMock.Mapping.ResponseToAsync(RequestMessage requestMessage)\r\n at WireMock.Owin.WireMockMiddleware.InvokeInternal(HttpContext ctx)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":null,"HResult":-2146233079,"Source":"System.Private.CoreLib","WatsonBuckets":null}"}

Can you please check?

Thanks,

Greg

Originally created by @gregoks on GitHub (Jul 31, 2019). Originally assigned to: @StefH on GitHub. Hi, When I accesed /__admin/requests I got the following exception: {"Status":"{\"ClassName\":\"System.InvalidOperationException\",\"Message\":\"Collection was modified; enumeration operation may not execute.\",\"Data\":null,\"InnerException\":null,\"HelpURL\":null,\"StackTraceString\":\" at System.Collections.Generic.List`1.Enumerator.MoveNextRare()\\r\\n at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\\r\\n at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\\r\\n at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)\\r\\n at WireMock.Server.FluentMockServer.ToJson[T](T result, Boolean keepNullValues)\\r\\n at WireMock.ResponseProviders.DynamicResponseProvider.ProvideResponseAsync(RequestMessage requestMessage, IFluentMockServerSettings settings)\\r\\n at WireMock.Mapping.ResponseToAsync(RequestMessage requestMessage)\\r\\n at WireMock.Owin.WireMockMiddleware.InvokeInternal(HttpContext ctx)\",\"RemoteStackTraceString\":null,\"RemoteStackIndex\":0,\"ExceptionMethod\":null,\"HResult\":-2146233079,\"Source\":\"System.Private.CoreLib\",\"WatsonBuckets\":null}"} Can you please check? Thanks, Greg
adam added the bug label 2025-12-29 14:24:52 +01:00
adam closed this issue 2025-12-29 14:24:53 +01:00
Author
Owner

@StefH commented on GitHub (Jul 31, 2019):

I'll take a look, probably I need to deep clone this collection when it's requested, so that you get a copy and not a reference.

@StefH commented on GitHub (Jul 31, 2019): I'll take a look, probably I need to deep clone this collection when it's requested, so that you get a copy and not a reference.
Author
Owner

@gregoks commented on GitHub (Jul 31, 2019):

thanks @StefH !

@gregoks commented on GitHub (Jul 31, 2019): thanks @StefH !
Author
Owner

@StefH commented on GitHub (Jul 31, 2019):

Can you try new version from MyGet?
WireMock.Net.1.0.26-ci-11549

@StefH commented on GitHub (Jul 31, 2019): Can you try new version from MyGet? WireMock.Net.1.0.26-ci-11549
Author
Owner

@gregoks commented on GitHub (Aug 1, 2019):

Sure, I'll run it for few days and see if it happens again since it doesnt happen always..

@gregoks commented on GitHub (Aug 1, 2019): Sure, I'll run it for few days and see if it happens again since it doesnt happen always..
Author
Owner

@gregoks commented on GitHub (Aug 9, 2019):

Havent seen this error since the fix.

@gregoks commented on GitHub (Aug 9, 2019): Havent seen this error since the fix.
Author
Owner

@StefH commented on GitHub (Aug 10, 2019):

I'll merge that PR to master and create a new NuGet.

In case this happens again, please open a new issue.

@StefH commented on GitHub (Aug 10, 2019): I'll merge that PR to master and create a new NuGet. In case this happens again, please open 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-wiremock#197