aws / aws/aws-lambda-nodejs-runtime-interface-client
Function URL invoke hangs when the response stream is empty
- 主要语言
- TypeScript
- 星标
- 224
- 派生
- 60
- PR 合并指标
- 30 天内没有已合并 PR
描述
I have a lambda with response streaming enabled. Invoked via Function URL. I am trying to return a status code with no response body. I have reduced my code to the below sample to reproduce the issue:
```js
// File: index.cjs
// Handler: index.handler
const pipeline = require("util").promisify(require("stream").pipeline);
const { Readable } = require("stream");
exports.handler = awslambda.streamifyResponse(async (event, responseStream, context) => {
responseStream = awslambda.HttpResponseStream.from(responseStream, {
statusCode: 403,
});
await pipeline(
Readable.from(Buffer.alloc(0)),
responseStream,
);
});
```
I can see the HTTP headers are sent correctly and received by the client. But the connection remains open for up to 16 minutes. It seems like the runtime expects a response body, and if there is none, it just hangs and does not close the connection.
What's even stranger is that I have tested this in 2 different accounts. One of the accounts has been created ages ago, and the code above actually works fine as one would expect. The other account is newer (and it's where that code is supposed to run), and it just hangs and doesn't close the connection. Region is `us-east-1`.
贡献指南
调研方向
从在 Function URL 调用中使用 awslambda.streamifyResponse、HttpResponseStream.from、pipeline 和 Readable.from(Buffer.alloc(0)) 复现 index.cjs 开始。在 us-east-1 中运行,并比较较旧和较新账户的行为。当 statusCode 403 的空响应流关闭客户端连接而不是一直挂起时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- aws, node.js, typescript
- 领域
- api, backend, cloud
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100