add a 60 sec. sleep between GitHub calls to avoid rate limits

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-10-24 10:30:56 +02:00
parent bca825b535
commit 3d122db60d
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 9 additions and 0 deletions

View File

@ -18,6 +18,13 @@ import {
} from "./fetchGithubRepo"; } from "./fetchGithubRepo";
import {fromRelationalViews as referenceDetectorFromRelationalViews} from "./referenceDetector"; import {fromRelationalViews as referenceDetectorFromRelationalViews} from "./referenceDetector";
/* sleep helper */
function sleep(seconds){
return new Promise(resolve => {
setTimeout(resolve, seconds*1000);
});
}
export interface Loader { export interface Loader {
declaration(): PluginDeclaration; declaration(): PluginDeclaration;
updateMirror( updateMirror(
@ -59,6 +66,8 @@ export async function updateMirror(
cache, cache,
}); });
reporter.finish(taskId); reporter.finish(taskId);
/* to avoid hitting GH API rate limits */
await sleep(60);
} }
} }