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

asked 8 months ago59 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions