-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fix handling of large streams #3
base: master
Are you sure you want to change the base?
Conversation
I'm seeing Is this something specific to .NET 6? Specific to record types? I might release a new version targeting .NET 6 then to keep up with the LTS releases. |
We use records for the majority of our entities thus the reproduction was created around them. It's possible it impacts normal classes but we haven't tested. |
Alright, this took me like an hour and half to debug you test example. If you limit the loop to like Specifically I found that the error started to occur between 178 and 179. The magic number is probably 16384 So the culprit is the buffer size... adding,
fixed the example. More importantly, a non-async deserialization,
works without any issue, The TupleAsJsonArray might not be at fault here. Thoughts? |
Known issue it seems: dotnet/runtime#74108 |
I think I found a much more worse problem with this logic:
This works:
The crazy thing is, all(?) the builtin converters does not seem to handle null directly and is not safe to invoke directly. But when used indirectly, via JsonSerializer, they work just fine. This is insane IMO and a very bad design, if my observations are correct. |
I am correct So this is a bug for sure. |
Hello @arogozine, we use this library extensively and ran into the below exception when deserializing large payloads with some unusually shaped records:
The issue only appears with very large entity counts and when using a stream.
Changing the implementation to always delegate the deserialization/serialization to the serializer instead of pulling out a converter appears to fix this issue. I'm not sure if this has an unintended side-effects but the tests continue to pass.