From f87534d4a7c725f305293675b86a2cc81c288291 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Sun, 31 Mar 2024 23:48:04 -0700 Subject: [PATCH] fix: streaming doesn't work when newline characters are malformed --- apps/cf-ai-backend/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts index 9b8eec8f..f4843601 100644 --- a/apps/cf-ai-backend/src/index.ts +++ b/apps/cf-ai-backend/src/index.ts @@ -167,7 +167,7 @@ export default { const encodedChunk = converter.encode("data: " + JSON.stringify({ "response": chunkText }) + "\n\n"); controller.enqueue(encodedChunk); } - const doneChunk = converter.encode("data: [DONE] \n\n"); + const doneChunk = converter.encode("data: [DONE]"); controller.enqueue(doneChunk); controller.close(); }