I'm putting a lot of traffic through request.get to resolve shortened URLs. I noticed that after my program has run for a bit it throws an exception:
if (self.req._reusedSocket && error.code === 'ECONNRESET'
TypeError: Cannot read property '_reusedSocket' of undefined
at ClientRequest.Request.init.self.clientErrorHandler (/home/ubuntu/node_modules/request/main.js:221:17)
at ClientRequest.EventEmitter.emit (events.js:96:17)
at Socket.socketOnData (http.js:1435:9)
at TCP.onread (net.js:404:27)
ubuntu@ip-10-145-181-135:~$ vi /home/ubuntu/node_modules/request/main.js
which looks like self.req is undefined.
It seems non-deterministic, since it fails after processing a few thousand URLs, when fetching a URL ... but the particular URL changes from run to run, with the exact same input.
Any advice would be welcome.
Fix for #417
you're getting an error emitted before that actual request goes out. i can't tell what the error is but i know it's before the request actually goes out so this should resolve the throw you're seeing and now you'll get the real error. the real error may still throw since i doubt any handlers have been added to it this early but at least you'll be able to find and debug the real problem.