@@ -210,50 +210,58 @@ class SessionManager {
210
210
}
211
211
212
212
private async sessionStarted ( command : AppiumCommand ) {
213
- sessionDebugMap . createNewSession ( this . sessionInfo . session_id ) ;
213
+ try {
214
+ sessionDebugMap . createNewSession ( this . sessionInfo . session_id ) ;
214
215
215
- this . driverScriptExecutor = new DriverScriptExecutor ( this . sessionInfo , command . driver ) ;
216
+ this . driverScriptExecutor = new DriverScriptExecutor ( this . sessionInfo , command . driver ) ;
216
217
217
- /* Check if the current session supports network profiling */
218
- if ( isHttpLogsSuppoted ( this . sessionInfo ) ) {
219
- pluginLogger . info ( "Creating network profiler" ) ;
220
- this . httpLogger = getHttpLogger ( {
221
- sessionInfo : this . sessionInfo ,
222
- adb : this . adb ,
223
- driver : command . driver ,
224
- } ) ;
225
- }
218
+ /* Check if the current session supports network profiling */
219
+ if ( isHttpLogsSuppoted ( this . sessionInfo ) ) {
220
+ pluginLogger . info ( "Creating network profiler" ) ;
221
+ this . httpLogger = getHttpLogger ( {
222
+ sessionInfo : this . sessionInfo ,
223
+ adb : this . adb ,
224
+ driver : command . driver ,
225
+ } ) ;
226
+ }
226
227
227
- let { desired } = this . sessionInfo . capabilities ;
228
- let buildName = desired [ "dashboard:build" ] ;
229
- let projectName = desired [ "dashboard:project" ] ;
230
- let name = desired [ "dashboard:name" ] ;
231
- let build , project ;
228
+ let { desired } = this . sessionInfo . capabilities ;
229
+ let buildName = desired [ "dashboard:build" ] ;
230
+ let projectName = desired [ "dashboard:project" ] ;
231
+ let name = desired [ "dashboard:name" ] ;
232
+ let build , project ;
232
233
233
- let { is_profiling_available, device_info } = await this . startAppProfiling ( ) ;
234
- await this . startHttpLogsCapture ( ) ;
234
+ let { is_profiling_available, device_info } = await this . startAppProfiling ( ) ;
235
+ await this . startHttpLogsCapture ( ) ;
235
236
236
- if ( projectName ) {
237
- project = await getOrCreateNewProject ( { projectName } ) ;
238
- }
239
- if ( buildName ) {
240
- build = await getOrCreateNewBuild ( { buildName, projectId : project ?. id } ) ;
241
- }
237
+ if ( projectName ) {
238
+ project = await getOrCreateNewProject ( { projectName } ) ;
239
+ }
240
+ if ( buildName ) {
241
+ build = await getOrCreateNewBuild ( { buildName, projectId : project ?. id } ) ;
242
+ }
242
243
243
- await this . initializeScreenShotFolder ( ) ;
244
- await this . startScreenRecording ( command . driver ) ;
245
- await Session . create ( {
246
- ...this . sessionInfo ,
247
- start_time : new Date ( ) ,
248
- build_id : build ?. build_id ,
249
- project_id : project ?. id || null ,
250
- device_info,
251
- is_profiling_available,
252
- name : name || null ,
253
- live_stream_port : await getMjpegServerPort ( command . driver , this . sessionInfo . session_id ) ,
254
- } as any ) ;
255
-
256
- await this . saveCommandLog ( command , null ) ;
244
+ await this . initializeScreenShotFolder ( ) ;
245
+ await this . startScreenRecording ( command . driver ) ;
246
+ await Session . create ( {
247
+ ...this . sessionInfo ,
248
+ start_time : new Date ( ) ,
249
+ build_id : build ?. build_id ,
250
+ project_id : project ?. id || null ,
251
+ device_info,
252
+ is_profiling_available,
253
+ name : name || null ,
254
+ live_stream_port : await getMjpegServerPort ( command . driver , this . sessionInfo . session_id ) ,
255
+ } as any ) ;
256
+
257
+ await this . saveCommandLog ( command , null ) ;
258
+ } catch ( err ) {
259
+ logger . error (
260
+ `Error saving new session info in database for session ${
261
+ this . sessionInfo . session_id
262
+ } . response: ${ JSON . stringify ( err ) } `
263
+ ) ;
264
+ }
257
265
}
258
266
259
267
public async sessionTerminated ( options : { sessionTimedOut : boolean } = { sessionTimedOut : false } ) {
0 commit comments