@@ -36,11 +36,15 @@ async function fetchInstalledRepos(event: H3Event) {
3636 for await ( const { installation } of app . eachInstallation . iterator ( ) ) {
3737 try {
3838 const octokit = await app . getInstallationOctokit ( installation . id ) ;
39- const installationRepos = await octokit . paginate (
39+ const installationRepos = [ ] ;
40+ for await ( const { data } of ( octokit as any ) . paginate . iterator (
4041 "GET /installation/repositories" ,
4142 { per_page : 100 } ,
42- ( response ) => response . data . repositories ,
43- ) ;
43+ ) ) {
44+ installationRepos . push (
45+ ...( Array . isArray ( data ) ? data : ( data . repositories ?? [ ] ) ) ,
46+ ) ;
47+ }
4448
4549 for ( const repo of installationRepos ) {
4650 if ( repo . private || seen . has ( repo . id ) ) {
@@ -93,11 +97,15 @@ async function getIndexedRepos(event: H3Event): Promise<{
9397 const cached =
9498 await bucket . getItem < RepoSearchIndexCache > ( REPO_INDEX_CACHE_KEY ) ;
9599
96- if ( cached && now - cached . fetchedAt < REPO_INDEX_CACHE_TTL_MS ) {
100+ if (
101+ cached &&
102+ cached . repos . length > 0 &&
103+ now - cached . fetchedAt < REPO_INDEX_CACHE_TTL_MS
104+ ) {
97105 return { repos : cached . repos , cacheStatus : "hit" } ;
98106 }
99107
100- if ( cached ) {
108+ if ( cached && cached . repos . length > 0 ) {
101109 const refreshPromise = revalidateRepoIndex ( event ) . catch ( ( err ) => {
102110 console . error ( "Failed to refresh repo index cache" , err ) ;
103111 } ) ;
0 commit comments