Skip to content

Commit 937fbb0

Browse files
committed
fix: handle stream close hangup crash
1 parent 3c8aab7 commit 937fbb0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/providers/google-vertex-ai/getBatchOutput.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,13 @@ export const BatchOutputRequestHandler: RequestHandler = async ({
143143
},
144144
});
145145

146+
const [safeStream] = responseStream.readable.tee();
147+
146148
// Pipe the node stream through the line splitter and then to the response stream.
147149
const lineSplitter = createLineSplitter();
148150
reader.pipeThrough(lineSplitter).pipeTo(responseStream.writable);
149151

150-
return new Response(responseStream.readable, {
152+
return new Response(safeStream, {
151153
headers: { 'Content-Type': 'application/octet-stream' },
152154
});
153155
};

0 commit comments

Comments
 (0)