@@ -14,6 +14,9 @@ import {
1414import { navigationItems } from '@components/Navigation/server'
1515import { clearConsentCookies } from '@test/e2e/helpers'
1616
17+ const DEFAULT_NAVIGATION_TIMEOUT = 5000
18+ const EXTENDED_NAVIGATION_TIMEOUT = 15000
19+
1720export class BasePage {
1821 readonly page : Page
1922 private _consoleMessages : string [ ] = [ ]
@@ -62,21 +65,26 @@ export class BasePage {
6265 * Automatically dismisses cookie consent modal unless skipCookieDismiss is true.
6366 */
6467 async goto ( path : string , options ?: { skipCookieDismiss ?: boolean ; timeout ?: number } ) : Promise < null | Response > {
65- const navigate = async ( ) => {
68+ const requestedTimeout = options ?. timeout ?? DEFAULT_NAVIGATION_TIMEOUT
69+
70+ const navigate = async ( timeout : number ) => {
6671 return await this . _page . goto ( path , {
67- timeout : options ?. timeout ?? 5000 ,
72+ timeout,
6873 waitUntil : 'domcontentloaded' ,
6974 } )
7075 }
7176
7277 let response : null | Response = null
7378
7479 try {
75- response = await navigate ( )
80+ response = await navigate ( requestedTimeout )
7681 } catch ( error ) {
7782 const message = error instanceof Error ? error . message : String ( error )
7883 if ( message . includes ( 'ERR_ABORTED' ) ) {
79- response = await navigate ( )
84+ response = await navigate ( requestedTimeout )
85+ } else if ( ! options ?. timeout && message . includes ( 'Timeout' ) ) {
86+ // Allow a single retry with a longer timeout to absorb slow prerender navigations
87+ response = await navigate ( EXTENDED_NAVIGATION_TIMEOUT )
8088 } else {
8189 throw error
8290 }
0 commit comments