Use showAndLogWarning to surface rateLimit
This commit is contained in:
@@ -11,6 +11,7 @@ import { Progress } from "vscode";
|
|||||||
import { CancellationToken } from "vscode-jsonrpc";
|
import { CancellationToken } from "vscode-jsonrpc";
|
||||||
import { throttling } from "@octokit/plugin-throttling";
|
import { throttling } from "@octokit/plugin-throttling";
|
||||||
import { Octokit } from "@octokit/rest";
|
import { Octokit } from "@octokit/rest";
|
||||||
|
import { showAndLogWarningMessage } from "../../helpers";
|
||||||
|
|
||||||
export async function getCodeSearchRepositories(
|
export async function getCodeSearchRepositories(
|
||||||
credentials: Credentials,
|
credentials: Credentials,
|
||||||
@@ -28,23 +29,15 @@ export async function getCodeSearchRepositories(
|
|||||||
const octokit = new MyOctokit({
|
const octokit = new MyOctokit({
|
||||||
auth,
|
auth,
|
||||||
throttle: {
|
throttle: {
|
||||||
onRateLimit: (
|
onRateLimit: (retryAfter: number, options: any): boolean => {
|
||||||
retryAfter: number,
|
void showAndLogWarningMessage(
|
||||||
options: any,
|
|
||||||
octokit: Octokit,
|
|
||||||
): boolean => {
|
|
||||||
octokit.log.warn(
|
|
||||||
`Request quota exhausted for request ${options.method} ${options.url}. Retrying after ${retryAfter} seconds!`,
|
`Request quota exhausted for request ${options.method} ${options.url}. Retrying after ${retryAfter} seconds!`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onSecondaryRateLimit: (
|
onSecondaryRateLimit: (_retryAfter: number, options: any): void => {
|
||||||
_retryAfter: number,
|
void showAndLogWarningMessage(
|
||||||
options: any,
|
|
||||||
octokit: Octokit,
|
|
||||||
): void => {
|
|
||||||
octokit.log.warn(
|
|
||||||
`SecondaryRateLimit detected for request ${options.method} ${options.url}`,
|
`SecondaryRateLimit detected for request ${options.method} ${options.url}`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user