fetch: errors from Node's bundled fetch have an empty stack
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
- 領域
- backend
調査の方向性
index-fetch.js を開き、__filename が未定義の場合に使われるフォールバック分岐と、issue で説明されている Error.captureStackTrace の呼び出しを調べます。V8 が利用可能なスタックフレームを取得できるよう、コンストラクターオプションを削除し、再現例に示されているように Node に組み込まれた fetch のエラーに呼び出し元のフレームが含まれることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Bug Description
Every error Node's built-in fetch rejects with has an empty stack: just the Name: message line, no frames. This started with #4812.
The cause is the fallback branch in index-fetch.js, taken when __filename is undefined, as in Node's bundled copy:
} else if (err && typeof err === 'object') {
Error.captureStackTrace(err, module.exports.fetch)
}
This runs inside the .catch callback, where fetch is no longer on the stack. When V8 can't find the constructorOpt frame it records no frames, so the stack ends up empty. Dropping the second argument fixes it.
Reproducible By
// repro.mjs: uses Node's global fetch (undici from npm takes the other branch)
async function caller (signal) {
await fetch('http://localhost:1', { signal })
}
await caller().catch(err => console.log(err.stack))
await caller(AbortSignal.abort(new Error('my reason'))).catch(err => console.log(err.stack))
Expected Behavior
Node 24.13.1 (undici 7.18.2):
TypeError: fetch failed
at node:internal/deps/undici/undici:16416:13
at async caller (file:///…/repro.mjs:2:3)
at async file:///…/repro.mjs:4:1
Error: my reason
at node:internal/deps/undici/undici:16416:13
at async caller (file:///…/repro.mjs:2:3)
at async file:///…/repro.mjs:5:1
Logs & Screenshots
Node 24.22.1 (undici 7.30.1) and 26.13.0 (undici 8.12.2):
TypeError: fetch failed
Error: my reason
Environment
macOS and Alpine Linux, both arm64. Affected: Node 24.22.1 and 26.13.0. The branch is unchanged on main.
- 主要言語
- JavaScript
- スター
- 7.7k
- フォーク
- 987
- 平均マージ
- 3日 8時間
- マージ済み PR(30日)
- 55
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nodejs/undici のほかの issue
-
setCookie turns finite out-of-range expires values into a Unix-epoch expiry対応中かも @vtxe02023274 が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
ProxyAgent: unsupported proxy scheme (e.g. socks5h:) reports "URL must start with http: or https:" even though socks5:/socks: are supported対応中かも @petrroll が 13 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Un-experimental DecompressInterceptor対応中かも @mcollina が 19 日前に担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
test-reliability
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Azure/azure-sdk-for-js#40672 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
txn2/mcp-data-platform#2492 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
liberation-data/drivine#639 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
accessibility ux
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
prophet-technocracy/civilizational-emergency-protocol#59 ·
メンテナーはふだん 1 日以内に返信
-
type: bug
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
RocketChat/Rocket.Chat#43554 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信