Merge pull request #2 from shadowlinyf/main

feat: can break the stream when st does
This commit is contained in:
蚊子
2024-05-03 21:16:25 +08:00
committed by GitHub
+8
View File
@@ -240,6 +240,14 @@ app.post("/v1/messages", (req, res) => {
console.log(e);
}
});
res.on("close", function () {
console.log(" > [Client closed]");
if (stream && typeof stream.destroy === 'function') {
stream.destroy();
}
});
stream.on("end", () => {
// send ending
res.write(createEvent("content_block_stop", { type: "content_block_stop", index: 0 }));