Every now and then, as I'm requesting data from a github-issue, I get this error when firing my request-promise-function:
{ RequestError: Error: read ECONNRESET
at new RequestError (/vagrant/node_modules/request-promise-core/lib/errors.js:14:15)
at Request.plumbing.callback (/vagrant/node_modules/request-promise-core/lib/plumbing.js:87:29)
at Request.RP$callback [as _callback] (/vagrant/node_modules/request-promise-core/lib/plumbing.js:46:31)
at self.callback (/vagrant/node_modules/request/request.js:187:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:191:7)
at Request.onRequestError (/vagrant/node_modules/request/request.js:859:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:191:7)
at TLSSocket.socketErrorListener (_http_client.js:358:9)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:191:7)
at emitErrorNT (net.js:1283:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
From previous event:
at Request.plumbing.init (/vagrant/node_modules/request-promise-core/lib/plumbing.js:36:28)
at Request.RP$initInterceptor [as init] (/vagrant/node_modules/request-promise-core/configure/request2.js:41:27)
at new Request (/vagrant/node_modules/request/request.js:129:8)
at request (/vagrant/node_modules/request/index.js:54:10)
at module.exports (/vagrant/resources/GetIssuesData.js:25:9)
at Socket.<anonymous> (/vagrant/app.js:42:13)
at emitNone (events.js:86:13)
at Socket.emit (events.js:188:7)
at /vagrant/node_modules/socket.io/lib/socket.js:503:12
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
name: 'RequestError',
message: 'Error: read ECONNRESET',
cause:
{ Error: read ECONNRESET
at exports._errnoException (util.js:1029:11)
at TLSWrap.onread (net.js:575:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' },
error:
{ Error: read ECONNRESET
at exports._errnoException (util.js:1029:11)
at TLSWrap.onread (net.js:575:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' },
options:
{ uri: 'https://api.github.com/repos/1dv023/jp222vq-examination-3/issues?access_token=TOKEN',
headers:
{ 'User-Agent': 'me',
'Content-Type': 'application/x-www-form-urlencoded' },
simple: false,
reconnect: true,
callback: [Function: RP$callback],
transform: undefined,
resolveWithFullResponse: false,
transform2xxOnly: false },
response: undefined }
The request is fired every time a user requests a new page on the application, and is also fired when changes are made in the github-issue. The request feeds a socket-eventemitter with data. This is the request-function:
(function() {
let rp = require("request-promise");
module.exports = function(res, callback) {
let options = {
uri: "https://api.github.com/repos/" + res.issue,
headers: {
"User-Agent": "Me",
"Content-Type": "application/x-www-form-urlencoded"
},
simple: false,
reconnect: true
};
rp(options)
.then(function(body, err) {
try {
body = JSON.parse(body);
let context = {
issues: body.map(function(issue) {
return {
title: issue.title,
comments: issue.comments,
uploaded: issue.created_at,
updated: issue.updated_at,
link: "/" + issue.number
};
}),
};
callback(context, null);
} catch (e) {
throw new Error(e)
}
})
.catch(function(err) {
callback(null, err);
});
};
}());
I've been scratching my head for ages now, trying to understand why I get this error. Tried to read up on ECONNRESET
, but didn't quite understand it. Can anybody please help?
via Jesper
No comments:
Post a Comment