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

gefragt vor 9 Monaten62 Aufrufe
Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen