storage: createReadStream() never errors when a download stalls mid-body
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, node.js, typescript
- 領域
- networking
調査の方向性
Start from File#createReadStream in the storage library and trace how it builds the underlying request through teeny-request/node-fetch, since the issue states the documented timeout no longer covers the response body after headers arrive (storage >= 8.0.1). The reproduction script (a local HTTP server that sends headers and a partial body) is the first thing to run to confirm the current hang. Done means a stalled stream emits an error after an idle interval and a test covers that path.
索引モデルが issue の本文から書いたものです。
説明
Library name
@google-cloud/storage
What would you like to see in the library?
An idle timeout for File#createReadStream(): if no body bytes arrive for a set time, the stream emits an error.
Why
A download that stops mid-body never emits an error or end, so a pipeline that reads from the stream waits forever. In production we see occasional downloads of multi-gigabyte objects stop partway through. Each one then hung for days until we stopped the process by hand.
This worked in early versions. In 2017, a stalled createReadStream() raised ESOCKETTIMEOUT (#2317), because the library used request, whose timeout set a socket idle timeout. That protection was lost later:
- With teeny-request 9.x / node-fetch 2 (storage ≤ 8.0.0), the request
timeoutstopped when the response headers arrived. node-fetch 2 applied its body timeout only to buffered reads (.text(),.json()), not to a piped stream. - With teeny-request ≥ 10 (storage ≥ 8.0.1), the documented
timeouthas no effect at all. See #9514.
googleapis/nodejs-storage#24 reports the same hang. Its last comment (storage 6.12, Node.js 20) also sees streams that hang forever.
Reproduction
storage 8.1.0, Node.js 22.22.1:
const http = require('node:http')
const { Storage } = require('@google-cloud/storage')
// The server sends the response headers and part of the body, then stops sending.
const server = http.createServer((req, res) => {
res.writeHead(200, { 'content-type': 'application/octet-stream' })
res.write('first part of the file\n')
})
server.listen(0, () => {
const storage = new Storage({
apiEndpoint: `http://127.0.0.1:${server.address().port}`,
projectId: 'repro',
useAuthWithCustomEndpoint: false,
})
let bytes = 0
storage.bucket('bucket').file('file.jsonl').createReadStream({ validation: false })
.on('data', (chunk) => { bytes += chunk.length })
.on('error', (err) => { console.log('error:', err.message); process.exit(0) })
.on('end', () => { console.log('end'); process.exit(0) })
setTimeout(() => {
console.log(`after 90 s: ${bytes} bytes received, no error, no end`)
process.exit(1)
}, 90000)
})
Output: after 90 s: 23 bytes received, no error, no end
Alternatives considered
We now wrap the stream in our own watchdog. It aborts the pipeline when no data moves for 10 minutes. Every user who streams large objects has to build the same thing. Node's built-in fetch (undici) has bodyTimeout for this case, with a default of 5 minutes.
- 主要言語
- TypeScript
- スター
- 3.2k
- フォーク
- 732
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 99
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
googleapis/google-cloud-node のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
googleapis/google-cloud-node#9854 ·
メンテナーはふだん 1 日以内に返信
-
pubsub: "Operation attempted on ended Span" when a modack is flushed after the message was ackedオープンapi: pubsub
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
googleapis/google-cloud-node#9853 ·
メンテナーはふだん 1 日以内に返信
-
storage: V4 getSignedUrl sorts canonical headers with localeCompare, so they disagree with X-Goog-SignedHeaders対応中かも @itsrayeedscodespace が 9 日前に担当しました。 オープンapi: storage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
googleapis/google-cloud-node#9840 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
firestore: getPartitions() emits gax AutopaginateTrueWarning in every process対応中かも @TheRealDanii が 12 日前に担当しました。 オープンapi: firestore
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
googleapis/google-cloud-node#9736 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
googleapis/google-cloud-node#9723 ·
メンテナーはふだん 1 日以内に返信
googleapis/google-cloud-node の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
oxc-project/tsrs#1010 ·
メンテナーはふだん 1 日以内に返信
-
area:infra area:storage bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
THU-MAIC/OpenMAIC#2311 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
docs documentation need-triage SaaS
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
enhancement from-app needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
nightly-labs/openbot#10973 ·
メンテナーはふだん 1 日以内に返信
-
status/need-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
google-gemini/gemini-cli#30328 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信