Uh oh!
There was an error while loading. Please reload this page.
[release/6.0] Enforce HttpClient limits on GetFromJsonAsync - #80552
Conversation
ghost
commented
Jan 12, 2023
Tagging subscribers to this area: @dotnet/ncl Issue DetailsBackport of a minimized change of #79386 to release/6.0 Customer ImpactTODO TestingTODO RiskTODO
|
carlossanlop
commented
Jan 12, 2023
Last day to merge backports for the February Release is tomorrow. Please fill out the template, make sure to mention the customer impact. Add the |
carlossanlop
commented
Jan 13, 2023
Talked to @MihaZupan. This will go in next month. |
MihaZupan
commented
Feb 6, 2023
carlossanlop
commented
Feb 8, 2023
Hey @ViktorHofer what should we do about this failure?: |
ViktorHofer
commented
Feb 8, 2023
That's happening because of dotnet/sdk@4c7675d. Apparently serviced SDKs now also warn about a TFM that moves out of support, even when that's long after the stable SDK itself shipped originally. We still produce net5.0 assets in our release/6.0 branch and we don't want to stop doing that. So we need an escape switch => You can suppress that error by setting |
karelz
commented
Feb 9, 2023
Approved by Tactics via email by @SteveMCarroll on 2/9. |
Backport of a minimized change of #79386 to release/6.0
Customer Impact
HttpClient has two properties users can tweak to limit the amount of time and resources spent on a given request (
TimeoutandMaxResponseContentBufferSize).GetFromJsonAsyncis inconsistent in the enforcement of these limits compared to other helpers (GetStringAsync,GetByteArrayAsync, andDeleteFromJsonAsync).There are three main ways to get the response content from HttpClient:
ResponseHeadersRead, asking the client not to buffer the response content as part of theSendAsynccallThis PR changes the behavior of the
client.GetFromJsonAsynchelper to match that ofGetStringAsyncand friends (case 1).This allows us to present consistent
HttpClientbehavior across the board.Testing
I added targeted CI tests that confirm limits are consistently enforced.
Risk
The enforcement of limits means that some requests that would previously succeed may now fail (either time out or exceed the size limit). It is unlikely that anyone is knowingly relying on this behavior given the inconsistencies mentioned above.
The default limits are also very large (100 seconds and 2 GB of content), so for a request to hit them, the user has most likely lowered them manually, indicating the intent that they do want them to be enforced. It also means that if they do run into issues, they can tweak the existing settings directly.
The change can also result in slightly higher memory consumption as we're buffering the whole body before we start the deserialization process. We do not expect this to be meaningfully impactful.