由于我正在从github问题请求数据,因此我在触发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 }
每次用户在应用程序上请求新页面时都会触发该请求,并且在github-issue中进行更改时也会触发该请求。该请求向socket-eventemitter提供数据。这是请求函数:
(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);
});
};
}());
我现在已经摸不着头脑了,试图理解为什么我会收到这个错误。试图阅读ECONNRESET
,但并不十分理解。有人可以帮忙吗?