Skip to content

Commit 72e9ca3

Browse files
committed
perf(streaming): avoid snapshot size allocation
1 parent f42074f commit 72e9ca3

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎src/server/responses-snapshot-repair.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ export function createResponsesSnapshotPayloadRewrite(
151151
): SsePayloadRewrite {
152152
const defaults = requestDefaults(requestBody);
153153
const completedItems = new Map<number, RetainedOutputItem>();
154-
const encoder = new TextEncoder();
155154
let aggregateItemBytes = 0;
156155
let reconstructionTainted = false;
157156

@@ -229,7 +228,7 @@ export function createResponsesSnapshotPayloadRewrite(
229228
retainCompletedItem(
230229
event.output_index as number,
231230
item,
232-
encoder.encode(JSON.stringify(item)).byteLength,
231+
Buffer.byteLength(JSON.stringify(item), "utf8"),
233232
);
234233
} else {
235234
reconstructionTainted = true;

0 commit comments

Comments
 (0)