MicrosoftDocs / winrt-api

WinRT reference content for developing Microsoft Universal Windows Platform (UWP) apps
Creative Commons Attribution 4.0 International
231 stars 500 forks source link

Setting default headers causes concurrent access errors (E_CHANGED_STATE) #2410

Closed martinraiberfc closed 1 year ago

martinraiberfc commented 1 year ago

Setting default headers before using a httpclient causes concurrent access errors (E_CHANGED_STATE: A concurrent or interleaved operation changed the state of the object, invalidating this operation.).

To reproduce see following example: https://gist.github.com/martinraiberfc/46ad7fc6e5c6e2516f09f78d1e234f3e

This perhaps needs to be documented or somehow fixed. As a work-around the headers can be set via a custom request filter.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

stevewhims commented 1 year ago

Thanks, @martinraiberfc. I'll investigate whether the behavior is considered a bug or not.

-Steve

stevewhims commented 1 year ago

UPDATE: Thanks for your patience: we can't reproduce the issue as described. So I'll go ahead and close this for now, but we can reopen if it different data comes in.

Thanks! -Steve

JunielKatarn commented 5 months ago

@stevewhims FYI. We have encountered this bug while developing a feature for React Native Windows. Had to implement a workaround.

The bug is intermittent, but we'll try to come up with a consistent reproducible case.

uroni commented 4 weeks ago

@JunielKatarn How did you workaround this issue? We worked around it by setting the HTTP headers in each request. The problem is that I guess that makes the multi-threading bug just harder to hit and we are currently running into this with wider testing.