@@ -101,6 +101,7 @@ export function ingestFromData(
101101export async function ingestListedFromGh (
102102 db ?: Database ,
103103 log : Logger | TestLoggerLike = realLog ,
104+ signal ?: AbortSignal ,
104105) : Promise < IngestReturn > {
105106 const token = getEnvStringRequired (
106107 "GITHUB_TOKEN" ,
@@ -109,14 +110,25 @@ export async function ingestListedFromGh(
109110 const lists : StarList [ ] = [ ] ;
110111 const s = log . spinner ( "Fetching lists..." ) . start ( ) ;
111112 let total = 0 ;
112- for await ( const l of getAllListsStream ( token , undefined , {
113- debug : ( ) => { } ,
114- } ) ) {
115- lists . push ( l ) ;
116- total ++ ;
117- s . text = `Loaded list ${ total } : ${ l . name } ` ;
113+ try {
114+ for await ( const l of getAllListsStream (
115+ token ,
116+ undefined ,
117+ {
118+ debug : ( ) => { } ,
119+ } ,
120+ signal ,
121+ ) ) {
122+ if ( signal ?. aborted ) throw new Error ( "Aborted" ) ;
123+ lists . push ( l ) ;
124+ total ++ ;
125+ s . text = `Loaded list ${ total } : ${ l . name } ` ;
126+ }
127+ s . succeed ( `Fetched ${ total } lists` ) ;
128+ } catch ( e ) {
129+ s . fail ?.( "Aborted" ) ;
130+ throw e ;
118131 }
119- s . succeed ( `Fetched ${ total } lists` ) ;
120132 const res = ingestFromData ( lists , undefined , db , log ) ;
121133 return {
122134 lists : res . lists ,
@@ -129,11 +141,19 @@ export async function ingestListedFromGh(
129141export async function ingestUnlistedFromGh (
130142 db ?: Database ,
131143 log : Logger | TestLoggerLike = realLog ,
144+ signal ?: AbortSignal ,
132145) : Promise < IngestReturn > {
133146 const svc = createStarsService ( starsLib , withDB ( db ) ) ;
134147 const s = log . spinner ( "Computing unlisted stars..." ) . start ( ) ;
135- const unlisted = await svc . read . getUnlistedStars ( ) ;
136- s . succeed ( `Found ${ unlisted . length } unlisted starred repositories` ) ;
148+ let unlisted : RepoInfo [ ] = [ ] ;
149+ try {
150+ if ( signal ?. aborted ) throw new Error ( "Aborted" ) ;
151+ unlisted = await svc . read . getUnlistedStars ( signal ) ;
152+ s . succeed ( `Found ${ unlisted . length } unlisted starred repositories` ) ;
153+ } catch ( e ) {
154+ s . fail ?.( "Aborted" ) ;
155+ throw e ;
156+ }
137157 const res = ingestFromData ( [ ] , unlisted , db , log ) ;
138158 return {
139159 lists : res . lists ,
0 commit comments