Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

download fails with TypeError: rawResponseStream.toJSON is not a function #528

@edeustace

Description

@edeustace

Environment details

  • OS: pop-os
  • Node.js version: 9.11.2
  • npm version: 5.7.1
  • @google-cloud/storage version: >=2.2.0 (works in 2.1.0)

Steps to reproduce

const { Storage } = require("@google-cloud/storage");
const s = new Storage();
const bucket = s.bucket("add-bucket-here");
const file = bucket.file("some-file-here.md");
file.download();

Expected: script runs successfully.
Actual: A TypeError occurs:

TypeError: rawResponseStream.toJSON is not a function
    at onResponse (/node_modules/@google-cloud/storage/build/src/file.js:413:51)
    at Util.handleResp (/node_modules/@google-cloud/common/build/src/util.js:123:9)
    at Duplexify.requestStream.on.on.res (/node_modules/@google-cloud/storage/build/src/file.js:392:31)
    at Duplexify.emit (events.js:180:13)
    at DestroyableTransform.emit (events.js:180:13)
    at onResponse (/node_modules/retry-request/index.js:194:19)
    at PassThrough.<anonymous> (/node_modules/retry-request/index.js:149:11)
    at PassThrough.emit (events.js:180:13)
    at /node_modules/teeny-request/build/src/index.js:186:29
    at <anonymous>

Had a look in the debugger - and this stream has no such function, it has a headers object though?

This commit fixes the issue. However I wouldn't be comfortable making a PR out of this because I'm casting to a Readable which may not always be the case?

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/nodejs-storage API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions