aws / aws/aws-lambda-nodejs-runtime-interface-client

Event on client disconnect/abort in a streaming response

Aberta
#145 1 comentário 6 reações 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
224
Forks
60
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

Im wondering if its possible to get any event emitted when a client aborts or disconnects during a streaming response with `awslambda.streamifyResponse`. I tried with this code, but from my testing it looks like theres no event emitted on the Lambda when that happens:
```ts
exports.handler = awslambda.streamifyResponse(
async (event, responseStream, context) => {
responseStream.setContentType('text/event-stream')
responseStream.on("close", ()=> {
// this never gets emitted at any point
console.log("responseStream closed");
});
for (let i = 0; i < 20; i++) {
await sleep(1000);
responseStream.write(`event: ping\n`);
responseStream.write(`data: ${i}\n\n`);
}
responseStream.end();
}
);
```

This would be an awesome feature to add in the age of SSR streaming, LLM's and more.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.