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

demandé il y a 9 mois61 vues
Aucune réponse

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions