@@ -118,23 +118,44 @@ export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMes
118118 }
119119 } , 1000 ) ;
120120 } )
121- await ctx . client . finalizeBuild ( ctx . build . id , ctx . totalSnapshots , ctx . log ) ;
121+
122+ for ( const [ sessionId , capabilities ] of ctx . sessionCapabilitiesMap . entries ( ) ) {
123+ try {
124+ const buildId = capabilities ?. buildId || '' ;
125+ const projectToken = capabilities ?. projectToken || '' ;
126+ const totalSnapshots = capabilities ?. snapshotCount || 0 ;
127+ const sessionBuildUrl = capabilities ?. buildURL || '' ;
128+ const testId = capabilities ?. id || '' ;
129+
130+ if ( buildId && projectToken ) {
131+ await ctx . client . finalizeBuildForCapsWithToken ( buildId , totalSnapshots , projectToken , ctx . log ) ;
132+ }
133+
134+ if ( testId && buildId ) {
135+ buildUrls += `TestId ${ testId } : ${ sessionBuildUrl } \n` ;
136+ }
137+ } catch ( error : any ) {
138+ ctx . log . debug ( `Error finalizing build for session ${ sessionId } : ${ error . message } ` ) ;
139+ }
140+ }
141+
142+ if ( ctx . build && ctx . build . id ) {
143+ await ctx . client . finalizeBuild ( ctx . build . id , ctx . totalSnapshots , ctx . log ) ;
144+ let uploadCLILogsToS3 = ctx ?. config ?. useLambdaInternal || uploadDomToS3ViaEnv ;
145+ if ( ! uploadCLILogsToS3 ) {
146+ ctx . log . debug ( `Log file to be uploaded` )
147+ let resp = await ctx . client . getS3PreSignedURL ( ctx ) ;
148+ await ctx . client . uploadLogs ( ctx , resp . data . url ) ;
149+ } else {
150+ ctx . log . debug ( `Skipping upload of CLI logs as useLambdaInternal is set` )
151+ }
152+ }
153+
122154 await ctx . browser ?. close ( ) ;
123155 if ( ctx . server ) {
124156 ctx . server . close ( ) ;
125157 }
126158
127- let uploadCLILogsToS3 = ctx ?. config ?. useLambdaInternal || uploadDomToS3ViaEnv ;
128- if ( ! uploadCLILogsToS3 ) {
129- ctx . log . debug ( `Log file to be uploaded` )
130- let resp = await ctx . client . getS3PreSignedURL ( ctx ) ;
131- await ctx . client . uploadLogs ( ctx , resp . data . url ) ;
132- } else {
133- ctx . log . debug ( `Skipping upload of CLI logs as useLambdaInternal is set` )
134- // ctx.log.debug(`Log file to be uploaded via LSRS`)
135- // let resp = ctx.client.sendCliLogsToLSRS(ctx);
136- }
137-
138159 if ( pingIntervalId !== null ) {
139160 clearInterval ( pingIntervalId ) ;
140161 ctx . log . debug ( 'Ping polling stopped immediately.' ) ;
0 commit comments