Lambda with invoke_type "RESPONSE_STREAM". Is it possible to detect if the client (end user) disconnected before a stream response is completed ? (nodejs)

0

I'm using the lambda with response streaming to proxy between the end user on the front end and an OpenAI API.

Our front end enables users to abort certain requests during streaming using the AbortController api (similar to the "stop generation" button on ChatGPT) ChatGPT stop generation button

Generally speaking in express or nodejs http we can listen to request cancellations from the client by using similar logic to :

request.socket.on("close", () =>{/** handle request abort logic here */})
// or the the deprecated object "connection"
request.connection.on("close", () =>{/** handle request abort logic here */})

is there a streamlined / recommended way to handle the same use case in streamed lambdas ?

Thanks in advance

已提问 9 个月前61 查看次数
没有答案

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容