You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This can block the threads (sync-over-async) when downloading large payloads. This problem doesn't exist in System.Text.Json as it uses the correct HttpContent.ReadFromJsonAsync in the SystemTextJsonContentSerializer.
One fix could be to download the data to an internally managed (preferably pooled) byte buffer before doing the deserialization via StreamReader + JsonTextReader. While this can increase the memory footprint, I think the other problem of blocking threads could be a bigger one comparatively.
Step to reproduce
The code that can block threads is here where line number 67 blocks threads on a network stream because the request is already sent with HttpCompletionOptions.ResponseHeaderRead as part of RequestBuilderImplementation classes.
This fix could potentially cause a regression for applications downloading and deserializing large payloads (>2GB because the backing char[] array is int indexed) using Refit today.
Users of Refit are generally calling another API, where one wouldn't expect such large payloads in response, so this could be OK. The safest fix might just be to use JsonTextReader over a char[] buffer (StreamReader) so that downloading from network stream is async and deserialization of bytes is sync.
Activity
cool-mist commentedon Mar 23, 2026
This fix could potentially cause a regression for applications downloading and deserializing large payloads (>2GB because the backing char[] array is int indexed) using Refit today.
Users of Refit are generally calling another API, where one wouldn't expect such large payloads in response, so this could be OK. The safest fix might just be to use JsonTextReader over a char[] buffer (StreamReader) so that downloading from network stream is async and deserialization of bytes is sync.
github-actions commentedon Apr 7, 2026
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.