Skip to content

Commit

Permalink
🔧 config: waitForRipeSessionTimeout default 5 seconds #3083
Browse files Browse the repository at this point in the history
  • Loading branch information
smashah committed Mar 30, 2023
1 parent 0d40823 commit cf5bd92
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/api/model/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ const isTosBlocked = (waPage: Page): Observable<string | boolean> => {
);
};

export const waitForRipeSession = async (waPage: Page): Promise<boolean> => {
export const waitForRipeSession = async (waPage: Page, waitForRipeSessionTimeout ?: number): Promise<boolean> => {
try {
await waPage.waitForFunction(`window.isRipeSession()`,
{ timeout: 0, polling: 'mutation' });
{ timeout: (waitForRipeSessionTimeout ?? 5) * 1000, polling: 1000 });
return true;
} catch (error) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
}
}
Expand Down

0 comments on commit cf5bd92

Please sign in to comment.