Request signal isn't aborted after garbage collection
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 272
描述
Bug Description
Passing a signal to Request() and aborting it does not cause the underlying request signal to be aborted after it's been garbage collected. This leads to issues where you want to listen on the request signal even after the request itself falls out of scope - e.g., the request is instantiated with an abort controller signal and downstream code is waiting for that signal to be aborted via request.signal.
Reproducible By
Run the following using node --expose-gc main.js:
const ac = new AbortController();
ac.signal.addEventListener("abort", () => {
console.log("ac signal aborted");
});
const request = new Request("https://google.ca", { signal: ac.signal });
request.signal.addEventListener("abort", () => {
console.log("request signal aborted");
});
setTimeout(() => {
global.gc();
ac.abort();
}, 0);
Expected Behavior
ac signal aborted and request signal aborted should be logged to the console.
Instead, only ac signal aborted is logged.
Environment
Latest node and undici. Tried it in some older versions as well.
Additional context
A few folks are running into this while trying to close event stream requests in the remix web framework. The underlying requests are never closed because the signal doesn't get aborted.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用 node --expose-gc 运行提供的 main.js 复现,然后跟踪 Request()、request.signal 和 AbortController 信号在相关 Node.js 实现中的传播。完成标准是在垃圾回收并 abort controller 后,同时记录 “ac signal aborted” 和 “request signal aborted”,并且为复现的用例添加 coverage。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, nodejs
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100