Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing to resumable GCS writestream throws errors #2382

Closed
zbjornson opened this issue Jun 12, 2017 · 4 comments
Closed

Writing to resumable GCS writestream throws errors #2382

zbjornson opened this issue Jun 12, 2017 · 4 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@zbjornson
Copy link
Contributor

Environment details

  • OS: Win 10
  • Node.js version: 6.10.3
  • npm version: 4
  • google-cloud-node version: 1.1.1

Steps to reproduce

var gcs = require("@google-cloud/storage")({projectId: "..."});
var bucket = gcs.bucket("mybucket");
var file = bucket.file("test.txt");
var ws = file.createWriteStream();
// then either:
require("fs").createReadStream("somefile").pipe(ws);
// or
ws.write("some text"); ws.end();

throws these errors:

> TypeError: Cannot read property 'length' of undefined                                                        
    at Upload.Duplexify._forward (node_modules\duplexify\index.js:161:76)                     
    at DestroyableTransform.onreadable (node_modules\duplexify\index.js:126:10)               
    at emitNone (events.js:86:13)                                                                              
    at DestroyableTransform.emit (events.js:185:7)                                                             
    at emitReadable_ (node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:434:10)                                                                                                     
    at emitReadable (node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:428:65)                                                                                                      
    at readableAddChunk (node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:224:35)                                                                                                  
    at DestroyableTransform.Readable.push node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:176:10)                                                                                
    at DestroyableTransform.Transform.push (node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:123:32)                                                                              
    at afterTransform (node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:79:51)                                                                                                    
> TypeError: Cannot read property 'crc32c' of undefined                                                        
    at Duplexify.<anonymous> (node_modules\@google-cloud\storage\src\file.js:1017:27)         
    at emitNone (events.js:86:13)                                                                              
    at Duplexify.emit (events.js:185:7)                                                                        
    at Upload.<anonymous> (node_modules\@google-cloud\storage\src\file.js:1888:11)            
    at emitNone (events.js:91:20)                                                                              
    at Upload.emit (events.js:185:7)                                                                           
    at finishMaybe (node_modules\readable-stream\lib\_stream_writable.js:485:14)              
    at afterWrite (node_modules\readable-stream\lib\_stream_writable.js:367:3)                
    at onwrite (node_modules\readable-stream\lib\_stream_writable.js:358:9)                   
    at Upload.WritableState.onwrite (node_modules\readable-stream\lib\_stream_writable.js:122:5)                                                                                                             

The error does not happen if the write stream is created with {resumable: false}. This is such a simple case to be failing that I feel like I must be doing something wrong...

@stephenplusplus
Copy link
Contributor

This should all come down to these lines in gcs-resumable-upload:

I'm a little stuck. I've tried to reproduce, but can't. Maybe with the outline above, you can think of where this can fail?

@zbjornson
Copy link
Contributor Author

Thanks for digging through that. This seems to be a fatal combination of allowed dependency versions. In a fresh directory, if I npm install @google-cloud/storage and then npm install [email protected], I get the errors. Version 3.5.0 works, so I think the storage module's package.json just needs to be updated. It still allows duplexify back to 3.2.0. Does that repro the problem for you?

@stephenplusplus
Copy link
Contributor

Sounds like this commit could be addressing the underlying problem, which was fixed in 3.4.4: mafintosh/duplexify@acf662f

Thanks for discovering that-- impressive! PR sent: #2385

@stephenplusplus stephenplusplus added api: storage Issues related to the Cloud Storage API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 13, 2017
@zbjornson
Copy link
Contributor Author

Thanks for the fast fix! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants