question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Header enumeration issues

See original GitHub issue

It 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:closed
  • Created a year ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
ebozdumancommented, Aug 11, 2022

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?

0reactions
ebozdumancommented, Aug 24, 2022

ok @itssimple. Thank you for confirming it. The issue is closed.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found