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

Exception ArgumentOutOfRangeException #846

Closed
arihantjain0894 opened this issue Nov 15, 2022 · 11 comments
Closed

Exception ArgumentOutOfRangeException #846

arihantjain0894 opened this issue Nov 15, 2022 · 11 comments
Assignees
Labels

Comments

@arihantjain0894
Copy link

arihantjain0894 commented Nov 15, 2022

Hi, I am getting the following exception:

System.ArgumentOutOfRangeException
Message: Index was out of range. Must be non-negative and less than the size of the collection.
InnerException: null 
StackTraceString: at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Collections.ObjectModel.ObservableCollection`1.RemoveItem(Int32 index)
at WireMock.Owin.WireMockMiddleware.LogRequest(LogEntry entry, Boolean addRequest)
at WireMock.Owin.WireMockMiddleware.InvokeInternalAsync(HttpContext ctx)
at WireMock.Owin.GlobalExceptionMiddleware.InvokeInternalAsync(HttpContext ctx)

Settings:
"MaxRequestLogCount": 0
"CustomDelay": 5000 ms

Version: 1.5.3

Usage: System stress testing.

When i increase the MaxRequestLogCount to let say 20, this is less frequent.
Also making custom delay to 0 fixes this.

@StefH StefH self-assigned this Nov 17, 2022
@StefH
Copy link
Collaborator

StefH commented Nov 17, 2022

#848

@StefH
Copy link
Collaborator

StefH commented Nov 17, 2022

can you try preview version "1.5.10-ci-16658" ?

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

@arihantjain0894
Copy link
Author

arihantjain0894 commented Nov 18, 2022

{
	"Status": "{\"ClassName\":\"System.ArgumentOutOfRangeException\",\"Message\":\"Index must be within the bounds of the List.\",\"Data\":null,\"InnerException\":null,\"HelpURL\":null,\"StackTraceString\":\"   at System.Collections.Generic.List`1.Insert(Int32 index, T item)\\r\\n   at System.Collections.ObjectModel.Collection`1.InsertItem(Int32 index, T item)\\r\\n   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)\\r\\n   at WireMock.Util.ConcurrentObservableCollection`1.InsertItem(Int32 index, T item)\\r\\n   at WireMock.Owin.WireMockMiddleware.LogRequest(LogEntry entry, Boolean addRequest)\\r\\n   at WireMock.Owin.WireMockMiddleware.InvokeInternalAsync(HttpContext ctx)\\r\\n   at WireMock.Owin.GlobalExceptionMiddleware.InvokeInternalAsync(HttpContext ctx)\",\"RemoteStackTraceString\":null,\"RemoteStackIndex\":0,\"ExceptionMethod\":null,\"HResult\":-2146233086,\"Source\":\"System.Private.CoreLib\",\"WatsonBuckets\":null,\"ParamName\":\"index\",\"ActualValue\":null}"
}

Maybe we need to add try-catch when adding log also.

@StefH
Copy link
Collaborator

StefH commented Nov 18, 2022

New preview version:

16663

Can you try this?

@StefH
Copy link
Collaborator

StefH commented Nov 19, 2022

Preview version 16667 does also have extra logic --> do not add an entry at all if the MaxRequestLogCount is set to 0.

@arihantjain0894 can you test this version?

@arihantjain0894
Copy link
Author

Shouldn't we do the same(condition) when removing from the log also?

@StefH
Copy link
Collaborator

StefH commented Nov 19, 2022

Ok.
I did add some extra checks

@StefH
Copy link
Collaborator

StefH commented Nov 19, 2022

latest version is 16669

@arihantjain0894
Copy link
Author

arihantjain0894 commented Nov 21, 2022

Worked fine. Thanks for the fix.

@StefH
Copy link
Collaborator

StefH commented Nov 21, 2022

#848

@StefH StefH closed this as completed Nov 21, 2022
@StefH
Copy link
Collaborator

StefH commented Nov 21, 2022

New official version will be released shortly.

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