Nodejs-storage: download fails with TypeError: rawResponseStream.toJSON is not a function

Created on 29 Nov 2018  路  4Comments  路  Source: googleapis/nodejs-storage

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: 
```shell
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?

storage p1 bug

Most helpful comment

@kinwa91 that update of fhinkel/teeny-request fixed me having the same issue. the speediness of the fix is much appreciated! :+1:

All 4 comments

With the same environment details, this also has broken our application.

Source code:

const f = getBucket(bucket)
  .file(file)
  .download()
  .then(contents => {
     // nothing happens, timeout
  })
  .catch(err => {
     // nothing happens, timeout
  });

@kinwa91 that update of fhinkel/teeny-request fixed me having the same issue. the speediness of the fix is much appreciated! :+1:

Since this appears to be fixed - I'm going to go ahead and close this out for now. If folks are still having trouble with the latest and greatest, please do let us know!

Was this page helpful?
0 / 5 - 0 ratings