aws / aws/aws-lambda-nodejs-runtime-interface-client
Event on client disconnect/abort in a streaming response
- Ngôn ngữ chính
- TypeScript
- Star
- 224
- Fork
- 60
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu tại điểm vào awslambda.streamifyResponse và kiểm tra vòng đời của responseStream, đặc biệt là nỗ lực thêm listener close được nêu trong issue. Xác định cách một client abort hoặc disconnect được biểu diễn, sau đó xác minh rằng một event được phát ra trong vòng lặp streaming và hành vi của nó được bao phủ bởi một test phù hợp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- aws, node.js, typescript
- Lĩnh vực
- backend-api-design
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100