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회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠