From f8b437347e5eb52554e6ec5c7165c5b5b83fae4e Mon Sep 17 00:00:00 2001 From: dphuang2 Date: Wed, 4 Dec 2024 13:19:28 -0800 Subject: [PATCH] handle api rate limit when search is not indexed --- .../konfig-next-app/src/utils/github-search-files.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/generator/konfig-next-app/src/utils/github-search-files.ts b/generator/konfig-next-app/src/utils/github-search-files.ts index 6e0813a03..64e97d295 100644 --- a/generator/konfig-next-app/src/utils/github-search-files.ts +++ b/generator/konfig-next-app/src/utils/github-search-files.ts @@ -80,6 +80,15 @@ export async function githubSearchFiles({ return result } catch (error) { + if ( + error instanceof Error && + error.message.includes('API rate limit exceeded') + ) { + console.warn( + '[GITHUB_SEARCH] GitHub API rate limit exceeded, returning null' + ) + return null + } if (error instanceof Error) throw new Error( `Error occurred while searching for files: ${error.message}`