Skip to content

Conversation

@liviu-gheorghe
Copy link

Fixes #224

});
page.setDefaultNavigationTimeout(60000);
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(this.context.config.browser.navigationTimeout || 60000);
Copy link
Member

@pavelfeldman pavelfeldman May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be called on the browser context in _setupBrowserContext

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pavelfeldman just to confirm, by this you mean updating the _setupBrowserContent method to something like this, while also reverting the modifs from src/tab.ts?

  private async _setupBrowserContext(): Promise<BrowserContextAndBrowser> {
    const { browser, browserContext } = await this._createBrowserContext();
    await this._setupRequestInterception(browserContext);
    for (const page of browserContext.pages()) {
      this._onPageCreated(page);
      // New Code Starts Here
      if (this.config.browser.navigationTimeout)
        page.setDefaultNavigationTimeout(this.config.browser.navigationTimeout);

      if (this.config.browser.timeout)
        page.setDefaultTimeout(this.config.browser.timeout);
      // New Code Ends Here
    }

    browserContext.on('page', page => this._onPageCreated(page));
    if (this.config.saveTrace) {
      await browserContext.tracing.start({
        name: 'trace',
        screenshots: false,
        snapshots: true,
        sources: false,
      });
    }
    return { browser, browserContext };
  }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I meant to set those on context.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify which part of the code you want me to change? I’m not really sure what you mean.

Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#437 (comment) - this should be enough of the clue. We expect familiarity with the Playwright API from the contributors.

@pavelfeldman
Copy link
Member

Looks good overall, minor comment and it is good to go.

README.md Outdated
example "1280, 720"
--vision Run server that uses screenshots (Aria snapshots
are used by default)
--navigation-timeout <ms> Maximum time to wait for navigation/load events,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are sorted alphabetically

src/program.ts Outdated
.option('--user-data-dir <path>', 'path to the user data directory. If not specified, a temporary directory will be created.')
.option('--viewport-size <size>', 'specify browser viewport size in pixels, for example "1280, 720"')
.option('--vision', 'Run server that uses screenshots (Aria snapshots are used by default)')
.option('--navigation-timeout <ms>', 'Maximum time to wait for navigation/load events, in milliseconds (default: 60000)')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(or rather these)

@pavelfeldman
Copy link
Member

Closing as non-converging.

@loia5tqd001
Copy link

Hi hi @pavelfeldman sorry what did you mean, I think allowing to set a custom timeout is a very valid case. I tried using playwright-mcp and it works for popular and fast pages but always prematurely disconnects for internal pages that are JS-heavy and slow.... orz

@TalHasonOasis
Copy link

@pavelfeldman Hey Pavel! I would like to reopen this, I see it's pretty much done, I can fix the last issues, in hope to merge it as it's a must for our usage of Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --navigation-timeout and --timeout options to override hard‑coded timeouts

4 participants