Skip to content

Reading a nonexisting file succeeds #772

Description

@marekbiskup

I tried to open an nonexisting file. It succeeded and gave me the following contents:

<?xml version='1.0' encoding='UTF-8'?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message></Error>

I'd prefer the function threw an exception of called 'error'.

My code

  var content = '';
  var readStream = bucket.file(data.name).createReadStream();
  readStream.on('data', function(buf) { content += buf.toString(); });
  readStream.on('end', function() {
    console.log("got file data: " + content);
  });
  readStream.on('error', function(err) {
    console.log("Error opening a gcs file " + data.name + ": " + err)
  });

output:
got file data: NoSuchKeyThe specified key does not exist.

EDIT: I actually also got an error message, see below.

Activity

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

Metadata

Metadata

Assignees

Labels

coretype: 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