Skip to content

storage: Make sure abort method exists before calling #878

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

Closed
stephenplusplus opened this issue Sep 21, 2015 · 0 comments
Closed

storage: Make sure abort method exists before calling #878

stephenplusplus opened this issue Sep 21, 2015 · 0 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

@stephenplusplus
Copy link
Contributor

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();
      });
@stephenplusplus stephenplusplus added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: storage Issues related to the Cloud Storage API. labels Sep 21, 2015
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