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