Closed antoinne85 closed 3 years ago
Some more research... I think this behavior is specific to 13.0.9+ as it seems to have been introduced here. (That's just speculation based on the commit message.)
hi, thanks for report. I also repro this issue. Please expect version 13.0.11 which will be released soon(middle of August).
Hi there, We are also getting an exception which originates within PostAsync
method of the same service i.e. Microsoft.BingAds.Internal.HttpService
.
The stack trace looks like this
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Net.Http.Headers.HttpHeaders.AddHeaderInfo(String headerName, HeaderStoreItemInfo sourceInfo)
at System.Net.Http.Headers.HttpHeaders.AddHeaders(HttpHeaders sourceHeaders)
at System.Net.Http.Headers.HttpRequestHeaders.AddHeaders(HttpHeaders sourceHeaders)
at System.Net.Http.HttpClient.PrepareRequestMessage(HttpRequestMessage request)
at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.PostAsync(Uri requestUri, HttpContent content, CancellationToken cancellationToken)
at Microsoft.BingAds.Internal.HttpService.PostAsync(Uri requestUri, List`1 formValues, TimeSpan timeout)
at Microsoft.BingAds.Internal.OAuth.UriOAuthService.<GetAccessTokensAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
Is this already been addressed and if so shall we expect the fix in the coming version 13.0.11...?
13.0.11 was published last Friday, Please try this version.
My company just upgraded to version 13.0.10 of the .NET SDK and we started getting an incredible amount of production issues. After several days of research on our own code, I believe we've found the issue.
Microsoft.BingAds.Internal.HttpService
has astatic
client
member of typeHttpClient
. On calls toUploadFileAsync
it executesaddHeadersAction(HttpService.client.DefaultRequestHeaders)
. So whatever headers are to be added get added to theDefaultRequestHeaders
and are carried on forever. The end result of this is that the headers forUser-Agent
,AuthenticationToken
,CustomerId
,DeveloperToken
andAccountId
grow and grow over time.In the [constructor of
BulkServiceManager
](), the instance propertyHttpService
is initialized to a newHttpService
.At
BulkServiceManager.cs:604
, inSubmitUploadAsyncImpl(...)
, theaddHeadersAction
is defined.At
BulkServiceManager.cs:631
,HttpService.UploadFileAsync
is called, passing inaddHeadersAction
.Stepping into that method you'll find
addHeadersAction(client.DefaultRequestHeaders)
.client
, in this case is a static member.To make a long story short, if you re-use the
BulkServiceManager
for multiple requests, you'll start accumulating headers and your requests will start failing.Back in this revision of
HttpService
things look to be correct. At some point it looks like the locally scopedclient
variable got promoted to a static member.