diff --git a/src/api/model/config.ts b/src/api/model/config.ts index 8265194c22..aae41ea177 100644 --- a/src/api/model/config.ts +++ b/src/api/model/config.ts @@ -357,6 +357,12 @@ export interface ConfigObject { * @default 60 */ qrTimeout?: number, + /** + * This determines how long the process should wait for a session to load fully before continuing the launch process. + * Set this to 0 to wait forever. Default is 5 seconds. + * @default 5 + */ + waitForRipeSessionTimeout?: number, /** * Some features, like video upload, do not work without a chrome instance. Set this to the path of your chrome instance or you can use `useChrome:true` to automatically detect a chrome instance for you. Please note, this overrides `useChrome`. */ diff --git a/src/controllers/auth.ts b/src/controllers/auth.ts index bf49bbcb1b..36507c5569 100644 --- a/src/controllers/auth.ts +++ b/src/controllers/auth.ts @@ -59,10 +59,10 @@ const isTosBlocked = (waPage: Page): Observable => { ); }; -export const waitForRipeSession = async (waPage: Page): Promise => { +export const waitForRipeSession = async (waPage: Page, waitForRipeSessionTimeout ?: number): Promise => { try { await waPage.waitForFunction(`window.isRipeSession()`, - { timeout: 0, polling: 'mutation' }); + { timeout: (waitForRipeSessionTimeout ?? 5) * 1000, polling: 1000 }); return true; } catch (error) { return false; diff --git a/src/controllers/initializer.ts b/src/controllers/initializer.ts index 2edc59738a..f4fece479c 100755 --- a/src/controllers/initializer.ts +++ b/src/controllers/initializer.ts @@ -291,7 +291,7 @@ export async function create(config: AdvancedConfig | ConfigObject = {}): Promis await waPage.evaluate("window.Store = undefined") if(config?.waitForRipeSession) { spinner.start("Waiting for ripe session...") - if(await waitForRipeSession(waPage)) spinner.succeed("Session ready for injection"); + if(await waitForRipeSession(waPage, config?.waitForRipeSessionTimeout)) spinner.succeed("Session ready for injection"); else spinner.fail("You may experience issues in headless mode. Continuing...") } }