Skip to content

storage: Make sure abort method exists before calling #878

@stephenplusplus

Description

@stephenplusplus

While playing around today, I noticed an error can occur before an API request is made. It's only on an HTTP stream that we get the abort method (to close the connection), so we have to check that it's available to call first.

From lib/storage/file.js:

  requestStream
      .on('error', function(err) {
        throughStream.destroy(err);
      })
      .on('response', function(res) {
        throughStream.emit('response', res);
        util.handleResp(null, res, null, onResponse);
      })
      .on('complete', function(res) {
        util.handleResp(null, res, null, onComplete);
      })
      .pipe(throughStream)
      .on('error', function() {
++      if (requestStream.abort) {
          requestStream.abort();
++      }
        requestStream.destroy();
      });

Metadata

Metadata

Labels

api: storageIssues related to the Cloud Storage API.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