Я делаю запрос к github api следующим образом:
exports.getPRDetails = (prLink) => {
return util.promisify(request)({
url: url,
headers: {
Authorization: `token ${constants.config.githubToken}`,
'User-Agent': 'my-agent'
},
json: true
}).then(
(response) => {
if (response.statusCode !== 200) {
console.log(`Request to ${url} got code ${response.statusCode} instead. ${response.body.message}`);
if (response.body.errorMessages) {
console.log(response.body.errorMessages);
}
return;
}
const prDetail = {
state: response.body.state,
commitSha: response.body.merge_commit_sha,
baseBranch: response.body.base.ref,
repoName: response.body.base.repo.full_name,
merged: response.body.merged};
return prDetail;
});
}
, и я так называю это
helpers.getPRDetails(prLink).then(prDetail => {
if (prDetail == null) {
main.addErrorMessage({id: `SPM-${issue.issueKey}`, description: fillTemplate(strings.JIRA_ERROR_RESOLVED_BUT_NO_PR_IN_DESCRIPTION, {prLink: prLink})});
}
else {
if (prDetail.state !== 'closed' || !prDetail.merged){
main.addErrorMessage({id: `SPM-${issue.issueKey}`, description: fillTemplate(strings.JIRA_ERROR_RESOLVED_BUT_NO_PR_UNMERGED, {prLink: prLink})});
}
if (constants.reposToCheck.includes(prDetail.repoName.toUpperCase())){
asyncCallsCount++;
helpers.checkIfBranchContainsCommit(prDetail.repoName, prDetail.commitSha, currentBranch, releaseBranch).then(containsCommit =>{
if (!containsCommit) {
errorMessage = fillTemplate(strings.JIRA_ERROR_RESOLVED_BUT_COMMIT_NOT_FOUND_IN_BRANCH, {releaseBranch: currentBranch, commitSha: prDetail.commitSha, prLink: prLink});
errorMessage += issue.resolvedTicketPRs.length > 1 ? fillTemplate(strings.JIRA_ERROR_RESOLVED_TICKET_HAS_MULTIPLE_PRS, {releaseBranch: currentBranch}) : '';
main.addErrorMessage({id: `SPM-${issue.issueKey}`, description: errorMessage});
}
asyncCallsCount--;
})
}
}
asyncCallsCount--;
});
Я замечаю, что получаю спецификацию c ошибка с трассировкой стека
(node:98756) UnhandledPromiseRejectionWarning: Error: Invalid protocol: agan:
at Request.init (/Users/myuser/myapp/node_modules/request/request.js:458:31)
at new Request (/Users/myuser/myapp/node_modules/request/request.js:127:8)
at request (/Users/myuser/myapp/node_modules/request/index.js:53:10)
at request (internal/util.js:235:26)
at Object.exports.getPRDetails (/Users/myuser/myapp/helpers.js:22:35)
at issue.resolvedTicketPRs.forEach (/Users/myuser/myapp/checks.js:38:25)
at Array.forEach (<anonymous>)
at checkResolvedTickets (/Users/myuser/myapp/checks.js:36:37)
at <anonymous>
(node:98756) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:98756) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Я не уверен, каким должен быть этот протокол agan
или откуда он взялся. Я знаю, что этот код работал в прошлом, поэтому не уверен, откуда эта ошибка.
Использование request@2.88.0
и util@0.10.3