bypass rate limit

This commit is contained in:
Namrata Jha
2021-12-22 09:59:18 +00:00
committed by GitHub
parent e6a9d9c802
commit 508f6970a5
4 changed files with 58 additions and 31 deletions
+9 -1
View File
@@ -1,8 +1,10 @@
import {from, Observable, merge, throwError, of} from 'rxjs'
import {catchError, map, tap} from 'rxjs/operators'
import {catchError, delay, map, tap} from 'rxjs/operators'
import {GraphQlQueryResponse} from '@octokit/graphql/dist-types/types'
import {graphql} from './graphql'
let deleted = 0
export interface DeletePackageVersionMutationResponse {
deletePackageVersion: {
success: boolean
@@ -20,6 +22,11 @@ export function deletePackageVersion(
packageVersionId: string,
token: string
): Observable<boolean> {
if (deleted === 99) {
console.log(`reaching rate limit`)
delay(5000)
}
deleted += 1
return from(
graphql(token, mutation, {
packageVersionId,
@@ -51,6 +58,7 @@ export function deletePackageVersions(
const deletes = packageVersionIds.map(id =>
deletePackageVersion(id, token).pipe(
tap(result => {
console.log(`versions Deleted 0 : ${deleted}`)
if (result) {
console.log(`version with id: ${id}, deleted`)
} else {