feat: add page navigation timeout

This commit is contained in:
RohitR311
2024-12-14 18:35:38 +05:30
parent 4469325925
commit 7f48464eea

View File

@@ -365,7 +365,7 @@ export default class Interpreter extends EventEmitter {
try { try {
const newPage = await context.newPage(); const newPage = await context.newPage();
await newPage.goto(link); await newPage.goto(link);
await newPage.waitForLoadState('networkidle'); await newPage.waitForLoadState('domcontentloaded');
await this.runLoop(newPage, this.initializedWorkflow!); await this.runLoop(newPage, this.initializedWorkflow!);
} catch (e) { } catch (e) {
// `runLoop` uses soft mode, so it recovers from it's own exceptions // `runLoop` uses soft mode, so it recovers from it's own exceptions
@@ -576,7 +576,7 @@ export default class Interpreter extends EventEmitter {
} }
await Promise.all([ await Promise.all([
nextButton.dispatchEvent('click'), nextButton.dispatchEvent('click'),
page.waitForNavigation({ waitUntil: 'networkidle' }) page.waitForNavigation({ waitUntil: 'domcontentloaded' })
]); ]);
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
@@ -767,6 +767,8 @@ export default class Interpreter extends EventEmitter {
public async run(page: Page, params?: ParamType): Promise<void> { public async run(page: Page, params?: ParamType): Promise<void> {
this.log('Starting the workflow.', Level.LOG); this.log('Starting the workflow.', Level.LOG);
const context = page.context(); const context = page.context();
page.setDefaultNavigationTimeout(100000);
// Check proxy settings from context options // Check proxy settings from context options
const contextOptions = (context as any)._options; const contextOptions = (context as any)._options;