@@ -120,21 +120,27 @@ export const zoektSearch = async (searchRequest: ZoektGrpcSearchRequest, prisma:
120120 const metadata = new grpc . Metadata ( ) ;
121121
122122 return new Promise ( ( resolve , reject ) => {
123- client . Search ( searchRequest , metadata , async ( error , response ) => {
123+ client . Search ( searchRequest , metadata , ( error , response ) => {
124124 if ( error || ! response ) {
125125 reject ( error || new Error ( 'No response received' ) ) ;
126126 return ;
127127 }
128128
129- const reposMapCache = await createReposMapForChunk ( response , new Map < string | number , Repo > ( ) , prisma ) ;
130- const { stats, files, repositoryInfo } = await transformZoektSearchResponse ( response , reposMapCache ) ;
131-
132- resolve ( {
133- stats,
134- files,
135- repositoryInfo,
136- isSearchExhaustive : stats . actualMatchCount <= stats . totalMatchCount ,
137- } satisfies SearchResponse ) ;
129+ ( async ( ) => {
130+ try {
131+ const reposMapCache = await createReposMapForChunk ( response , new Map < string | number , Repo > ( ) , prisma ) ;
132+ const { stats, files, repositoryInfo } = await transformZoektSearchResponse ( response , reposMapCache ) ;
133+
134+ resolve ( {
135+ stats,
136+ files,
137+ repositoryInfo,
138+ isSearchExhaustive : stats . totalMatchCount <= stats . actualMatchCount ,
139+ } satisfies SearchResponse ) ;
140+ } catch ( err ) {
141+ reject ( err ) ;
142+ }
143+ } ) ( ) ;
138144 } ) ;
139145 } ) ;
140146}
0 commit comments