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

Event on client disconnect/abort in a streaming response

未关闭
#145 1 条评论 6 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
224
派生
60
PR 合并指标
30 天内没有已合并 PR

描述

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.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。