From ba505c37ef7a6265e63ea5eb25ae6150441700f6 Mon Sep 17 00:00:00 2001 From: Nino Floris Date: Mon, 27 Oct 2025 12:52:58 +0100 Subject: [PATCH] Fix streaming threshold value Closes #5978 --- src/Npgsql/Internal/Converters/JsonConverter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Npgsql/Internal/Converters/JsonConverter.cs b/src/Npgsql/Internal/Converters/JsonConverter.cs index 77157875b3..074575e4e1 100644 --- a/src/Npgsql/Internal/Converters/JsonConverter.cs +++ b/src/Npgsql/Internal/Converters/JsonConverter.cs @@ -107,8 +107,8 @@ public override ValueTask WriteAsync(PgWriter writer, T? value, CancellationToke static class JsonConverter { public const byte JsonbProtocolVersion = 1; - // We pick a value that is the largest multiple of 4096 that is still smaller than the large object heap threshold (85K). - const int StreamingThreshold = 81920; + // Largest value that is a power of 2 and a multiple of 4096 while staying under the large object heap threshold (85K). + const int StreamingThreshold = 65536; public static bool TryReadStream(bool jsonb, Encoding encoding, PgReader reader, out int byteCount, [NotNullWhen(true)]out Stream? stream) {