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

オープン 初心者向け
#5,116 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #5127 @umeraamir69 による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
backend, testing

調査の方向性

packages/trigger-sdk/src/v3/retry.tsから始め、既存のリトライテストとあわせてretryFetchを読みます。issueにある3つの中断ケースを再現します。中断された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時間
マージ済み PR(30日)
17

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

triggerdotdev/trigger.dev のほかの issue

triggerdotdev/trigger.dev の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。