Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/pipeline/frame_json_array.zig
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ pub const JsonArrayFramer = struct {
const byte = chunk[i];
i += 1;
if (isJsonWhitespace(byte)) continue;
try self.writeClose(out);
try self.enterDesync(out, chunk[i - 1 ..]);
return;
},
Expand Down Expand Up @@ -469,6 +470,23 @@ test "truncated input flushes buffered bytes and closes best-effort" {
try testing.expectEqualStrings("[{\"a\":1},{\"b\":]", got);
}

test "trailing junk after complete array keeps closing brackets" {
for ([_]usize{ 1, 7, 4096 }) |chunk| {
var sink: TestSink = .{ .allocator = testing.allocator };
defer sink.deinit();
const got = try runChunked("[1]extra", chunk, 64, &sink);
defer testing.allocator.free(got);
try testing.expectEqualStrings("[1]extra", got);
}
for ([_]usize{ 1, 7, 4096 }) |chunk| {
var sink: TestSink = .{ .allocator = testing.allocator };
defer sink.deinit();
const got = try runChunked("[](", chunk, 64, &sink);
defer testing.allocator.free(got);
try testing.expectEqualStrings("[](", got);
}
}

test "stats are accounted" {
const input = "[1,\"drop\",\"swap\",2]";
var sink: TestSink = .{ .allocator = testing.allocator };
Expand Down
Loading