Skip to content

File write stream does not error when writing to a file in a non-existent bucket #436

Description

@theacodes

When using file.createWriteStream when the file was created on a non-existent bucket, the stream does not error and essentially acts as if everything is fine. The only indication of error is the fact that no file is uploaded.

In the example below, one would expect the error event to trigger:

var gcloud = require('gcloud');

var storage = gcloud.storage({
  keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS,
  projectId: process.env.GCLOUD_PROJECT_ID
})

var bucket = storage.bucket('this-bucket-does-not-exist');

var file = bucket.file('file.ext');
var stream = file.createWriteStream();

stream.on('error', function(){ console.log('Error'); });
stream.on('finish', function(){ console.log('Done'); });

stream.write('data');
stream.end();

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    api: storageIssues related to the Cloud Storage API.
    on Mar 10, 2015
  2. added this to the Storage Stable milestone on Mar 10, 2015
  3. ryanseys commented on Mar 10, 2015

    @ryanseys
    Contributor

    This is caused by handleError being used for all the things and the error is a 404 (bucket not found), which no amount of startUpload will solve.

  4. ryanseys commented on Mar 10, 2015

    @ryanseys
    Contributor

    @jonparrott Also you should use the complete event rather than the finish event. :) We have a bug opened at #435 to address this as well.

  5. theacodes commented on Mar 10, 2015

    @theacodes
    Author

    Great, I'll switch over to the complete event. Will keep a lookout for the merged PR.

  6. 24 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions