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 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
node.js, typescript
領域
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 摘要。