storage 9.0.0: non-resumable uploads read the whole body into memory before sending
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 56/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
- 領域
- backend, performance
調査の方向性
Start with File#startSimpleUpload_ and the reqOpts.multipart branch in build/cjs/src/storage-transport.js, then compare the multipart request path with version 8.4.0. Reproduce with the supplied fake-gcs-server script and check both memory use on a large non-resumable upload and the payload containing the boundary string. Done when stream uploads stay bounded in memory and that payload is stored intact.
索引モデルが issue の本文から書いたものです。
説明
Package: @google-cloud/storage (handwritten/storage)
Environment
@google-cloud/storage9.0.0 (gaxios 8.3.3, google-auth-library 11.3.4)- Node 22.23.4 (same under Bun 1.4.4)
- 8.4.0 streams the same upload
Steps to reproduce
Against fake-gcs-server (docker run -p 4443:4443 fsouza/fake-gcs-server -scheme http -backend memory), so no bucket or credentials are needed:
import { Readable } from "node:stream";
import { pipeline } from "node:stream/promises";
import { Storage } from "@google-cloud/storage";
import { PassThroughClient } from "google-auth-library";
const apiEndpoint = "http://127.0.0.1:4443";
await fetch(`${apiEndpoint}/storage/v1/b?project=p`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ name: "repro-bucket" }),
});
// PassThroughClient only because of a separate 9.0.0 change: a custom apiEndpoint now asks for credentials.
const storage = new Storage({ projectId: "p", apiEndpoint, authClient: new PassThroughClient() });
const MiB = 256;
let sent = 0;
const source = new Readable({
read() {
this.push(sent < MiB ? Buffer.alloc(1024 * 1024, sent++ & 255) : null);
},
});
let peak = 0;
const timer = setInterval(() => (peak = Math.max(peak, process.memoryUsage().rss)), 10);
await pipeline(
source,
storage.bucket("repro-bucket").file("big.bin").createWriteStream({ resumable: false }),
);
clearInterval(timer);
console.log({ peakRssMiB: Math.round(peak / 2 ** 20) });
Actual (9.0.0)
Peak RSS grows with the size of the upload:
| upload | 8.4.0 | 9.0.0 |
|---|---|---|
| 32 MiB | 114 MiB | 169 MiB |
| 256 MiB | 128 MiB | 842 MiB |
Under Bun 1.4.4, the 256 MiB upload peaks at 74 MiB on 8.4.0 and 1,065 MiB on 9.0.0. file.save(data, { resumable: false }) takes the same path. Resumable uploads still stream (about 45 MiB for 256 MiB).
Expected (8.4.0)
The media part is streamed, so memory stays flat whatever the size of the upload.
Cause
File#startSimpleUpload_ passes the write stream as the second multipart part (content: writeStream), and StorageTransport.makeRequest (build/cjs/src/storage-transport.js, the reqOpts.multipart branch) collects every chunk of a stream part into an array and Buffer.concat()s it before the request goes out. 8.x streamed the parts through teeny-request's multipart stream.
A second problem in the same code
The multipart boundary is now the fixed string ===============storage_multipart_boundary== (8.x used a random UUID per request), so content that contains that line breaks the framing. Saving this 62-byte buffer with resumable: false:
Buffer.from("before\r\n--===============storage_multipart_boundary==\r\nafter\r\n")
8.4.0 stores it intact. On 9.0.0, fake-gcs-server rejects the upload with 500 malformed MIME header: missing colon: "after".
Suggested fix
Stream a stream part into the request body instead of buffering it, and generate a random boundary for each request.
- 主要言語
- 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 が 13 日前に担当しました。 オープン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時間 初心者へのやさしさ 67/100
ilan-pinto/roaring-lions#1552 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug: [React Native/Android] KeepAliveService never starts when CAMERA is not granted (Android 14+)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cloudflare/realtimekit-ui#208 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
usebruno/bruno-vscode#235 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信