Skip to content

Unhandled stream error in pipe #1163

@JustinBeckwith

Description

@JustinBeckwith

Disclaimer: this may be a gcloud-node problem or a GCS problem - not really sure.

I'm working on a project where I download a lot of images and then upload them in parallel to GCS. When the number of simultaneous operations against GCS trend towards 100-200, I get a bunch of random connection reset failures on /some/ requests:

[Error: Could not authenticate request read ECONNRESET]

When I trend towards 300 simultaneous operations, the app just crashes outright with this error:

stream.js:74
      throw er; // Unhandled stream error in pipe.
      ^

Error: socket hang up
    at createHangUpError (_http_client.js:200:15)
    at Socket.socketOnEnd (_http_client.js:292:23)
    at emitNone (events.js:72:20)
    at Socket.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)

I boiled this down to a fairly small repro:

var request = require('request');
var uuid = require('node-uuid');
var util = require('util');
var gcloud = require('gcloud')({
  projectId: 'YOUR PROJECT ID',
  keyFilename: 'keyfile.json'
});

var storage = gcloud.storage();
var bucket = storage.bucket('scaletest');
var count = 0;

for (var i=0; i<200; i++) {
  (function() {
    var idx = count++;
    var name = uuid.v4();
    var file = bucket.file(name);
    console.log('Request #' + idx);
    request("http://jbeckwith.com/images/head.png")
      .pipe(file.createWriteStream())
      .on('finish', () => {
        console.log("Success! #" + idx);
        file.delete();
      }).on('error', (err) => {
        console.error("Fail! #" + idx + "\n\t" + util.inspect(err));
      });
  })();
}

setInterval(()=>{},1000);

And a package.json:

{
  "name": "maxconn",
  "version": "1.0.0",
  "description": "",
  "main": "test.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "gcloud": "^0.29.0",
    "node-uuid": "^1.4.7",
    "request": "^2.69.0"
  }
}

I suspect there's an endpoint in GCP throttling the number of active connections from a single client, and I'm bumping up on that limit.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions