Header enumeration issues
See original GitHub issueIt works most of the time, but when we have many requests at the same time for the same resource, we sometimes end up with this (and other exceptions, that doesn’t make any sense)
Version of SDK: 4.0.5 Using .NET 6.0
Exception:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at System.Net.Http.Headers.HttpHeaders.ReadStoreValues[T](Span`1 values, Object storeValue, HttpHeaderParser parser, Int32& currentIndex)
at System.Net.Http.Headers.HttpHeaders.GetStoreValuesAsStringOrStringArray(HeaderDescriptor descriptor, Object sourceValues, String& singleValue, String[]& multiValue)
at System.Net.Http.Headers.HttpHeaders.GetEnumeratorCore()+MoveNext()
at Minio.ResponseResult.get_Headers() in /root/.q/sources/minio-dotnet/Minio/ResponseResult.cs:line 113
at Minio.MinioClient.StatObjectAsync(StatObjectArgs args, CancellationToken cancellationToken) in /root/.q/sources/minio-dotnet/Minio/ApiEndpoints/ObjectOperations.cs:line 1095
at Minio.MinioClient.getObjectHelper(GetObjectArgs args, CancellationToken cancellationToken) in /root/.q/sources/minio-dotnet/Minio/Helper/OperationsHelper.cs:line 50
Code (snippet) used to get the file:
var outFile = new MemoryStream();
var getObjectArgs = new GetObjectArgs()
.WithBucket(bucketName)
.WithObject(minioObjectName)
.WithCallbackStream((s) =>
s.CopyTo(outFile)
);
await _minioClient.GetObjectAsync(getObjectArgs, cancellationToken: cancellationToken);
outFile.Seek(0, SeekOrigin.Begin);
return File(outFile, dbfr.MimeType, null, true);
Issue Analytics
- State:
- Created a year ago
- Comments:14
Top Results From Across the Web
Enum class defined in header file does not work in struct ...
When I define TypeEnum in AnotherHeader.h it says enum class redefinition as it should; Changing to TypeEnum to enum instead of enum class...
Read more >API Proposal: Non-validated HttpHeaders enumeration ...
There are a few issues, here: Validation. TryAddWithoutValidation can be used to add request headers to be sent, and those headers will ...
Read more >How to identify and exploit HTTP Host header vulnerabilities
In this section, we'll look more closely at how you can identify whether a website is vulnerable to HTTP Host header attacks. We'll...
Read more >HTTP Security Response Headers Cheat Sheet
Proper HTTP response headers can help prevent security vulnerabilities like Cross-Site Scripting, Clickjacking, Information disclosure and more. In this cheat ...
Read more >Cannot refer to enum in header
With enums you must use two colons between the name and the enumerator: ... I will let you know if I can find...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
One more thing: It is almost always suggested to add/call
ConfigureAwait(false)
after an awaited async method, like:await _minioClient.GetObjectAsync(getObjectArgs, cancellationToken: cancellationToken)
.ConfigureAwait(false)
;
It means that you do not care if the code after the await, runs on the captured context or not, unless otherwise is true in your scenario. This will also help performance.
Could you apply this change, if it is ok, and then try to reproduce the issue?
ok @itssimple. Thank you for confirming it. The issue is closed.