@@ -199,6 +199,7 @@ class GitLabRepoLoader {
199199
200200 let branchesPage = [ ] ;
201201 while ( ( branchesPage = await this . fetchNextPage ( branchesRequestData ) ) ) {
202+ if ( ! Array . isArray ( branchesPage ) || ! branchesPage ?. length ) break ;
202203 this . branches . push ( ...branchesPage . map ( ( branch ) => branch . name ) ) ;
203204 }
204205 return this . #branchPrefSort( this . branches ) ;
@@ -221,6 +222,7 @@ class GitLabRepoLoader {
221222 let filesPage = null ;
222223 let pagePromises = [ ] ;
223224 while ( ( filesPage = await this . fetchNextPage ( filesRequestData ) ) ) {
225+ if ( ! Array . isArray ( filesPage ) || ! filesPage ?. length ) break ;
224226 // Fetch all the files that are not ignored in parallel.
225227 pagePromises = filesPage
226228 . filter ( ( file ) => {
@@ -258,6 +260,7 @@ class GitLabRepoLoader {
258260 let issuesPage = null ;
259261 let pagePromises = [ ] ;
260262 while ( ( issuesPage = await this . fetchNextPage ( issuesRequestData ) ) ) {
263+ if ( ! Array . isArray ( issuesPage ) || ! issuesPage ?. length ) break ;
261264 // Fetch all the issues in parallel.
262265 pagePromises = issuesPage . map ( async ( issue ) => {
263266 const discussionsRequestData = {
@@ -269,6 +272,7 @@ class GitLabRepoLoader {
269272 while (
270273 ( discussionPage = await this . fetchNextPage ( discussionsRequestData ) )
271274 ) {
275+ if ( ! Array . isArray ( discussionPage ) || ! discussionPage ?. length ) break ;
272276 discussions . push (
273277 ...discussionPage . map ( ( { notes } ) =>
274278 notes . map (
@@ -308,6 +312,7 @@ ${body}`
308312 } ;
309313
310314 const wikiPages = await this . fetchNextPage ( wikiRequestData ) ;
315+ if ( ! Array . isArray ( wikiPages ) ) return [ ] ;
311316 console . log ( `Total wiki pages fetched: ${ wikiPages . length } ` ) ;
312317 return wikiPages ;
313318 }
0 commit comments