feat: can break the stream when st does

This commit is contained in:
shadowlin
2024-05-03 21:09:51 +08:00
parent ce31383ce3
commit 37793f9688
+8
View File
@@ -240,6 +240,14 @@ app.post("/v1/messages", (req, res) => {
console.log(e); console.log(e);
} }
}); });
res.on("close", function () {
console.log(" > [Client closed]");
if (stream && typeof stream.destroy === 'function') {
stream.destroy();
}
});
stream.on("end", () => { stream.on("end", () => {
// send ending // send ending
res.write(createEvent("content_block_stop", { type: "content_block_stop", index: 0 })); res.write(createEvent("content_block_stop", { type: "content_block_stop", index: 0 }));