Skip to content

Lack of error handling while uploading a file. #422

Description

@teddybearz

If the network connection is lost (e.g. cable pulled), the node process will exit because of an error even that has no handler registered.

Need some fix like:

diff --git a/node_modules/gcloud/lib/storage/file.js b/node_modules/gcloud/lib/storage/file.js
index 8e1a26e..4aaec72 100644
--- a/node_modules/gcloud/lib/storage/file.js
+++ b/node_modules/gcloud/lib/storage/file.js
@@ -913,11 +915,20 @@

     var writeStream = request(reqOpts);
     writeStream.callback = util.noop;
-
+    var errorHandled = false;
+    writeStream.on('error', function(err) {
+      if (!errorHandled) {
+         errorHandled = true;
+         handleError(err);
+      }
+    });
     writeStream.on('complete', function(res) {
       util.handleResp(null, res, res.body, function(err, data) {
         if (err) {
-          handleError(err);
+          if (!errorHandled) {
+             errorHandled = true;
+             handleError(err);
+          }
           return;
         }

Activity

  1. ryanseys commented on Mar 4, 2015

    @ryanseys
    Contributor

    I'll look into this.

  2. self-assigned this
    on Mar 4, 2015
  3. 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 4, 2015
  4. ryanseys commented on Mar 5, 2015

    @ryanseys
    Contributor

    Fixed in #426

  5. 20 remaining items

  6. added 2 commits that reference this issue on Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions