teeny-request: the timeout option is ignored since 10.0.0 (node-fetch 3 has no timeout option)

オープン
#9,514 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

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

調査の方向性

Start at requestToFetchOptions, where reqOpts.timeout is copied into node-fetch 3 options that no longer honor it; the reproduction script in the issue is the test to run, and done means the callback fires after ~1000 ms with a timeout error instead of hanging. Run it against the installed teeny-request build before changing anything to confirm the regression. Heed the issue's caveat that a blanket AbortSignal.timeout would truncate streaming downloads, so inspect the streaming path and decide between a signal and an agent socket idle timeout.

索引モデルが issue の本文から書いたものです。

説明

Library name

teeny-request

Versions

teeny-request 11.0.1 (also 10.x), node-fetch 3.3.2, Node.js 22.22.1

Description

requestToFetchOptions copies reqOpts.timeout into the node-fetch options. node-fetch 3 removed the timeout option, so the value is silently ignored, and a request to a server that never responds waits forever.

This is a regression from teeny-request 10.0.0, which moved from node-fetch 2 to node-fetch 3. With teeny-request 9.0.0 (node-fetch 2.7.0), the same request fails after the timeout.

It affects every library that passes timeout to teeny-request. For example, @google-cloud/storage sets timeout: 60000 as a default for all requests (nodejs-common/util.js). Since storage 8.0.1, which depends on teeny-request ^11, that timeout has no effect.

Reproduction
const http = require('node:http')
const { teenyRequest } = require('teeny-request')

// The server accepts the request and never sends response headers.
const server = http.createServer(() => {})
server.listen(0, () => {
  const url = `http://127.0.0.1:${server.address().port}/`
  const startedAt = Date.now()
  teenyRequest({ uri: url, timeout: 1000 }, (err) => {
    console.log(`callback after ${Date.now() - startedAt} ms:`, err?.message)
    process.exit(0)
  })
  setTimeout(() => {
    console.log(`no callback after ${Date.now() - startedAt} ms`)
    process.exit(1)
  }, 5000)
})

Output with teeny-request 11.0.1 (node-fetch 3.3.2):

no callback after 5010 ms

Output with teeny-request 9.0.0 (node-fetch 2.7.0):

callback after 1003 ms: network timeout at: http://127.0.0.1:50922/
Expected behavior

The request fails after about 1000 ms, as it does with teeny-request 9.x.

One possible fix is to pass signal: AbortSignal.timeout(reqOpts.timeout) to fetch. That limits the total request time, which would cut off long streaming downloads, so streaming requests may need a socket idle timeout on the agent instead. In node-fetch 2, the timeout stopped at the response headers for a streamed body.

Related: #9515 (a stalled @google-cloud/storage download never errors).

主要言語
TypeScript
スター
3.2k
フォーク
732
平均マージ
2日 11時間
マージ済み PR(30日)
99

環境構築

はじめの一歩

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

googleapis/google-cloud-node のほかの issue

googleapis/google-cloud-node の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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