@@ -3,12 +3,13 @@ import GitlabHelper from './gitlabHelper';
33import settings from '../settings' ;
44
55import { Octokit as GitHubApi } from '@octokit/rest' ;
6+ import { throttling } from '@octokit/plugin-throttling' ;
67import { Gitlab } from '@gitbeaker/node'
78
89import * as fs from 'fs' ;
910
1011import AWS from 'aws-sdk' ;
11-
12+ import { sleep } from './utils' ;
1213
1314const issueCounters = {
1415 nrOfPlaceholderIssues : 0 ,
@@ -51,8 +52,10 @@ const gitlabApi = new Gitlab({
5152 token : settings . gitlab . token ,
5253} ) ;
5354
55+ const MyOctokit = GitHubApi . plugin ( throttling ) ;
56+
5457// Create a GitHub API object
55- const githubApi = new GitHubApi ( {
58+ const githubApi = new MyOctokit ( {
5659 debug : false ,
5760 baseUrl : settings . github . baseUrl
5861 ? settings . github . baseUrl
@@ -63,6 +66,22 @@ const githubApi = new GitHubApi({
6366 accept : 'application/vnd.github.v3+json' ,
6467 } ,
6568 auth : 'token ' + settings . github . token ,
69+ throttle : {
70+ onRateLimit : async ( retryAfter , options ) => {
71+ console . log (
72+ `Request quota exhausted for request ${ options . method } ${ options . url } `
73+ ) ;
74+ await sleep ( 60000 ) ;
75+ return true ;
76+ } ,
77+ onAbuseLimit : async ( retryAfter , options ) => {
78+ console . log (
79+ `Abuse detected for request ${ options . method } ${ options . url } `
80+ ) ;
81+ await sleep ( 60000 ) ;
82+ return true ;
83+ } ,
84+ } ,
6685} ) ;
6786
6887const gitlabHelper = new GitlabHelper ( gitlabApi , settings . gitlab ) ;
0 commit comments