bug: retry.fetch ignores the caller's abort signal and retries aborted requests

未关闭 适合新手
#5,116 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

  • #5127 来自 @umeraamir69 —— 已关闭,未合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
backend, testing

调研方向

从packages/trigger-sdk/src/v3/retry.ts开始,结合现有的重试测试阅读retryFetch。重现 issue 中的三种中止情况:已中止的init.signal、已中止的Request信号,以及已经处于中止状态的信号。完成标准是每种情况都会以AbortError拒绝,且不会发送重试;issue 说测试已准备好,但没有指出测试文件。

由索引模型根据 Issue 内容生成。

描述

Provide environment information

@trigger.dev/sdk 4.8.4 (main at 1fec779), Node 24.4.1, macOS.

Describe the bug

retry.fetch doesn't stop when the caller aborts, unlike fetch:

  1. Aborting init.signal mid-request is retried as a timeout. retryFetch can't tell the caller's AbortError from its own timeoutInMs, so it waits out the backoff and sends the request again, and the resend can't be aborted.
  2. The signal of a Request input is ignored. retryFetch only listens to init.signal.
  3. A signal that is already aborted still sends the request, because its abort event never fires.

All three are in retryFetch in packages/trigger-sdk/src/v3/retry.ts.

Reproduction repo

N/A

To reproduce

Inside a task, against an endpoint that takes about 500ms to respond:

const a = new AbortController();
setTimeout(() => a.abort(), 100);
await retry.fetch(url, { signal: a.signal }); // resolves 200 after resending

const b = new AbortController();
setTimeout(() => b.abort(), 100);
await retry.fetch(new Request(url, { signal: b.signal })); // resolves 200

await retry.fetch(url, { signal: AbortSignal.abort() }); // sends the request, resolves 200

fetch rejects with AbortError in all three cases.

Suggested fix

Use init.signal, falling back to the Request's signal, link it to every attempt (including when it is already aborted), and don't retry an abort that came from it. I have this ready with tests.

Additional information

Found while working on #2490.

主要语言
TypeScript
星标
16.5k
派生
1.5k
平均合并
1 天 15 小时
30 天内合并 PR
17

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

triggerdotdev/trigger.dev 的其他 Issue

查看 triggerdotdev/trigger.dev 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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