@@ -21,6 +21,9 @@ import {
21
21
* - session data SHOULD be cleared between specs in run mode
22
22
*/
23
23
export default function ( Commands , Cypress , cy ) {
24
+ // 20s timeout used for internal cy commands within the session command
25
+ const INTERNAL_COMMAND_TIMEOUT = 20_000
26
+
24
27
const sessionsManager = new SessionsManager ( Cypress , cy )
25
28
const sessions = sessionsManager . sessions
26
29
@@ -149,7 +152,7 @@ export default function (Commands, Cypress, cy) {
149
152
message : '' ,
150
153
type : 'system' ,
151
154
} , ( setupLogGroup ) => {
152
- return cy . then ( async ( ) => {
155
+ return cy . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , async ( ) => {
153
156
// Catch when a cypress command fails in the setup function to correctly update log status
154
157
// before failing command and ending command queue.
155
158
cy . state ( 'onQueueFailed' , ( err , _queue ) => {
@@ -180,7 +183,7 @@ export default function (Commands, Cypress, cy) {
180
183
cy . breakSubjectLinksToCurrentChainer ( )
181
184
}
182
185
} )
183
- . then ( async ( ) => {
186
+ . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , async ( ) => {
184
187
cy . state ( 'onQueueFailed' , null )
185
188
const data = await sessions . getCurrentSessionData ( )
186
189
@@ -241,7 +244,7 @@ export default function (Commands, Cypress, cy) {
241
244
}
242
245
} ,
243
246
} , ( validateLog ) => {
244
- return cy . then ( async ( ) => {
247
+ return cy . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , async ( ) => {
245
248
const isValidSession = true
246
249
let caughtCommandErr = false
247
250
let _commandToRunAfterValidation
@@ -350,7 +353,7 @@ export default function (Commands, Cypress, cy) {
350
353
throw err
351
354
}
352
355
353
- _commandToRunAfterValidation = cy . then ( async ( ) => {
356
+ _commandToRunAfterValidation = cy . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , async ( ) => {
354
357
Cypress . state ( 'onQueueFailed' , null )
355
358
356
359
if ( caughtCommandErr ) {
@@ -434,16 +437,16 @@ export default function (Commands, Cypress, cy) {
434
437
* 2. validate session
435
438
*/
436
439
const createSessionWorkflow = ( existingSession , step : 'create' | 'recreate' ) => {
437
- return cy . then ( async ( ) => {
440
+ return cy . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , async ( ) => {
438
441
setSessionLogStatus ( statusMap . inProgress ( step ) )
439
442
440
443
await navigateAboutBlank ( )
441
444
await sessions . clearCurrentSessionData ( )
442
445
443
446
return cy . whenStable ( ( ) => createSession ( existingSession , step ) )
444
447
} )
445
- . then ( ( ) => validateSession ( existingSession , step ) )
446
- . then ( async ( isValidSession : boolean ) => {
448
+ . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , ( ) => validateSession ( existingSession , step ) )
449
+ . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , async ( isValidSession : boolean ) => {
447
450
if ( ! isValidSession ) {
448
451
return 'failed'
449
452
}
@@ -462,15 +465,15 @@ export default function (Commands, Cypress, cy) {
462
465
* 3. if validation fails, catch error and recreate session
463
466
*/
464
467
const restoreSessionWorkflow = ( existingSession : Cypress . SessionData ) => {
465
- return cy . then ( async ( ) => {
468
+ return cy . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , async ( ) => {
466
469
setSessionLogStatus ( statusMap . inProgress ( SESSION_STEPS . restore ) )
467
470
await navigateAboutBlank ( )
468
471
await sessions . clearCurrentSessionData ( )
469
472
470
473
return restoreSession ( existingSession )
471
474
} )
472
- . then ( ( ) => validateSession ( existingSession , SESSION_STEPS . restore ) )
473
- . then ( ( isValidSession : boolean ) => {
475
+ . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , ( ) => validateSession ( existingSession , SESSION_STEPS . restore ) )
476
+ . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , ( isValidSession : boolean ) => {
474
477
if ( ! isValidSession ) {
475
478
return createSessionWorkflow ( existingSession , SESSION_STEPS . recreate )
476
479
}
@@ -495,7 +498,7 @@ export default function (Commands, Cypress, cy) {
495
498
}
496
499
497
500
return logGroup ( Cypress , groupDetails , ( log ) => {
498
- return cy . then ( async ( ) => {
501
+ return cy . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , async ( ) => {
499
502
_log = log
500
503
501
504
if ( ! session . hydrated ) {
@@ -511,7 +514,7 @@ export default function (Commands, Cypress, cy) {
511
514
}
512
515
513
516
return restoreSessionWorkflow ( session )
514
- } ) . then ( ( status : 'created' | 'restored' | 'recreated' | 'failed' ) => {
517
+ } ) . then ( { timeout : INTERNAL_COMMAND_TIMEOUT } , ( status : 'created' | 'restored' | 'recreated' | 'failed' ) => {
515
518
return navigateAboutBlank ( )
516
519
. then ( ( ) => {
517
520
setSessionLogStatus ( status )
0 commit comments