clearbit / clearbit-node

Node library for querying the Clearbit business intelligence APIs
https://clearbit.com/docs
MIT License
69 stars 35 forks source link

Error: Socket Hang Up on Enrichment API #21

Closed mlynch closed 6 years ago

mlynch commented 7 years ago

Hi,

I'm doing a daily batch of a couple thousand emails to the Enrichment API. I don't set stream: true and I handle the results through the webhook API.

Here's a snippet of how I'm doing this:

  clearbit.Enrichment.find({
    email: user.email
  }).then(function(response) {
    var person = response.person;
    var company = response.company;
    // Let the webhook handle inserting
    done();

    //insertData(db, done, user, person, company);

  }).catch(clearbit.Enrichment.QueuedError, function(err) {
    done();
    // This is fine
    // Our webhook will get the data
  }).catch(function(err) {
    done();
    console.error('ERROR LOOKING UP', err);
  })

What I'm noticing is, after a couple hundred calls to clearbit.Enrichment.find, the calls start erroring out with this stack trace:

ERROR LOOKING UP { [Error: socket hang up]
  cause: { [Error: socket hang up] code: 'ECONNRESET' },
  isOperational: true,
  code: 'ECONNRESET' }
Trace
    at Function.<anonymous> (/app/bin/worker.js:56:13)
    at Function.tryCatcher (/app/node_modules/clearbit/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/app/node_modules/clearbit/node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (/app/node_modules/clearbit/node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (/app/node_modules/clearbit/node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (/app/node_modules/clearbit/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/app/node_modules/clearbit/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/clearbit/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:371:17)

Related to #3?

maccman commented 6 years ago

I'm assuming this is the limitations on local sockets? Closing for now.