Skip to content

feat: add persistent browser context handling #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

amitdeshmukh
Copy link

  • Add _persistentContext property to store and reuse browser context
  • Cache and reuse existing persistent context if available. This ensures subsequent tool calls do not fail with the error Failed to create a ProcessSingleton for your profile directory
  • Improve browser context management efficiency

- Add _persistentContext property to store and reuse browser context
- Cache and reuse existing persistent context if available
- Improve browser context management efficiency
src/context.ts Outdated
private async _launchPersistentContext(): Promise<playwright.BrowserContext> {
// If we already have a persistent context, return it.
if (this._persistentContext) {
Copy link
Member

Choose a reason for hiding this comment

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

It should be higher up, in _ensureBrowserContext

Copy link
Author

Choose a reason for hiding this comment

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

you're right, made the required changes and pushing another commit into the PR

- Consolidate persistent context handling into _ensureBrowserContext
- Optimize cleanup by running context/browser closures in parallel
- Only set persistent context for local browser instances
- Move _persistentContext property with other context properties

This change simplifies the browser context management code while maintaining
the same functionality, making it more maintainable and efficient.
@amitdeshmukh
Copy link
Author

@microsoft-github-policy-service agree

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.

2 participants