You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Storage Emulator: PUT /upload/storage/v1/b/:bucketId/o ignores Content-Range and prematurely finalizes multi-chunk resumable uploads with HTTP 200 (deadlocks @google-cloud/storage) #11583
Start the Firebase Storage Emulator (firebase emulators:start --only storage).
Stream an object larger than chunkSize using @google-cloud/storagefile.createWriteStream({ resumable: true, chunkSize: 256 * 1024 }) (the GCS SDK splits the upload into multiple PUT requests with Content-Range: bytes <start>-<end>/*).
The emulator appends the chunk bytes and responds with HTTP 308 Resume Incomplete (with a Range header acknowledging received bytes) while keeping the upload session ACTIVE.
Only once the final chunk completes the upload should finalizeResumableUpload run and return HTTP 200 OK.
[REQUIRED] Actual behavior
In src/emulator/storage/apis/gcloud.ts, the PUT /upload/storage/v1/b/:bucketId/o handler does not inspect Content-Range and unconditionally calls finalizeResumableUpload(uploadId) on the very first PUT:
Because the first chunk receives HTTP 200 OK instead of 308 Resume Incomplete:
@google-cloud/storage's Upload stream assumes the entire upload finished after the first chunk and emits uploadFinished without draining the rest of the Node.js Writable stream.
The producer (pipeline / stream.write) waits for backpressure drain or stream completion that never arrives, causing the upload promise to hang indefinitely with no error.
Note: PUT in gcloud.ts also uses bodyParser.raw({ type: "*/*", limit: "130mb" }), which currently caps single-request uploads at 130 MiB when chunkSize is omitted as a workaround; supporting multi-chunk Content-Range uploads with HTTP 308 would also allow streaming uploads larger than 130 MiB (as long as each individual chunk is ≤ 130 MiB).
Activity