-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync stream serialization not handling IAsyncEnumerable correctly #66687
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsWhile adding new tests to System.Text.Json I discovered an issue with the handling of IAsyncEnumerable values in the new sync stream serialization APIs. It would seem like IAsyncEnumerableConverter's sync serialization detection logic is not adequate in identifying the new methods: in debug builds this results in a failed debug assertion whereas release builds end up serializing IAE values successfully, since they accidentally perform sync-over-async enumeration of the source enumerable. We should try to fix this, I can see a couple of options here:
|
Would this be deterministic, i.e. regardless of the async enumerable's contents, whether it's empty or not, whether its operations complete synchronously or not, you'd always get the exception because it'd be based on the shape rather than on the data? |
Good question. For the non-streaming sync serialization methods the converter throws outright (i.e. it's based on the type shape). It's conceivable that we could make it more adaptable but I suspect this might be setting traps for users (e.g. my mocked IAsyncEnumerable responses were passing all unit tests but serialization is crashing when I deploy the app). |
…ly (dotnet#67035) * Fix dotnet#66687 * enable small buffer async tests for collections
While adding new tests to System.Text.Json I discovered an issue with the handling of IAsyncEnumerable values in the new sync stream serialization APIs. It would seem like IAsyncEnumerableConverter's sync serialization detection logic is not adequate in identifying the new methods: in debug builds this results in a failed debug assertion whereas release builds end up serializing IAE values successfully, since they accidentally perform sync-over-async enumeration of the source enumerable. We should try to fix this, I can see a couple of options here:
cc @steveharter @stephentoub
The text was updated successfully, but these errors were encountered: