Open TEJA2312 opened 1 year ago
Here is my full code to stream data from chatgpt:-
late to the party, but it appears to be an issue where your request was already ended.
depending on how you handle the requests, you might have to explicitly state that you don't want to send a "final" response and use your own response handling.
for example, when using koa
you'd have to set ctx.respond = false
because otherwise koa would already handle the response and thus it's no longer possible to send any data to that client since the connection closes.
I am not able to stream responses to my front end. this the error Im getting:-
uncaught exception silently logged: Error: write after end at new NodeError (node:internal/errors:399:5) at write_ (node:_http_outgoing:890:11) at ServerResponse.write (node:_http_outgoing:849:15) at u.flush (/Users/tejasshirnalkar/Documents/GitHub/main_api/node_modules/better-sse/build/index.js:1:3337) at u.push (/Users/tejasshirnalkar/Documents/GitHub/main_api/node_modules/better-sse/build/index.js:1:3450) at IncomingMessage.<anonymous> (/Users/tejasshirnalkar/Documents/GitHub/main_api/src/modules/brieflyai/service/brieflyai_service.js:61:30) at IncomingMessage.emit (node:events:513:28) at IncomingMessage.emit (node:domain:489:12) at IncomingMessage.Readable.read (node:internal/streams/readable:539:10) at flow (node:internal/streams/readable:1023:34) at resume_ (node:internal/streams/readable:1004:3) at processTicksAndRejections (node:internal/process/task_queues:82:21) { code: 'ERR_STREAM_WRITE_AFTER_END' }