Skip to content

Commit

Permalink
Remove rate limit warning
Browse files Browse the repository at this point in the history
Signed-off-by: paulober <[email protected]>
  • Loading branch information
paulober committed Sep 12, 2024
1 parent 0a8ea76 commit a1de07c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/utils/download.mts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ async function downloadAndInstallGithubAsset(
existsSync(targetDirectory) &&
readdirSync(targetDirectory).length !== 0
) {
Logger.info(
Logger.debug(
LoggerSource.downloader,
`${logName} ${version} is already installed.`
);
Expand Down
39 changes: 3 additions & 36 deletions src/utils/githubREST.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import GithubApiCache, {
} from "./githubApiCache.mjs";
import { type RequestOptions, request } from "https";
import { unknownErrorToString, unknownToError } from "./errorHelper.mjs";
import { env, Uri, window } from "vscode";
import { window } from "vscode";

// TODO: move into web consts
export const HTTP_STATUS_OK = 200;
Expand Down Expand Up @@ -249,11 +249,9 @@ async function getReleases(repository: GithubRepository): Promise<string[]> {

return getReleases(repository);
} else if (response.status === HTTP_STATUS_FORBIDDEN) {
githubApiForbidden();

// return the default response as without a PAT
// ther is no way a rerun will succeed in the near future
throw new Error("GitHub API Code 403 Forbidden");
throw new Error("GitHub API Code 403 Forbidden. Rate limit exceeded.");
} else if (response.status !== 200) {
throw new Error("Error http status code: " + response.status);
}
Expand Down Expand Up @@ -367,11 +365,9 @@ export async function getGithubReleaseByTag(

return getGithubReleaseByTag(repository, tag);
} else if (response.status === HTTP_STATUS_FORBIDDEN) {
githubApiForbidden();

// return the default response as without a PAT
// ther is no way a rerun will succeed in the near future
throw new Error("GitHub API Code 403 Forbidden");
throw new Error("GitHub API Code 403 Forbidden. Rate limit exceeded.");
} else if (response.status !== 200) {
throw new Error("Error http status code: " + response.status);
}
Expand Down Expand Up @@ -431,32 +427,3 @@ export async function githubApiUnauthorized(): Promise<void> {
);
await Settings.getInstance()?.updateGlobal(SettingsKey.githubToken, "");
}

/**
* Show rate limit exceeded warning to the user.
*/
export function githubApiForbidden(): void {
Logger.warn(
LoggerSource.githubRestApi,
"GitHub API Code 403 Forbidden. Probably rate limit exceeded."
);
// show a rate limit warning to the user
void window
.showWarningMessage(
"GitHub API rate limit exceeded. Please try again later." +
"Consider adding a GitHub Personal Access Token in the settings " +
"to increase your rate limit.",
"More Info"
)
.then(selection => {
if (selection === "More Info") {
env.openExternal(
Uri.parse(
"https://github.com/raspberrypi/pico-vscode" +
"/?tab=readme-ov-file#github-api-rate-limit-error-" +
"while-retrieving-sdk-and-toolchain-versions"
)
);
}
});
}

0 comments on commit a1de07c

Please sign in to comment.