Skip to content

Fix launch_server, to be able to use persistent_context and user_data_dir#398

Open
pierorolando1 wants to merge 1 commit intodaijro:mainfrom
pierorolando1:fix-launchserver-persistent-context
Open

Fix launch_server, to be able to use persistent_context and user_data_dir#398
pierorolando1 wants to merge 1 commit intodaijro:mainfrom
pierorolando1:fix-launchserver-persistent-context

Conversation

@pierorolando1
Copy link

Issue #253

When attempting to use persistent_context and user_data_dir parameters in launch_server():

launch_server(
    # ...
    persistent_context=True,
    user_data_dir='my-user-data-dir'
    # ...
)

These parameters are completely ignored - they are not read, parsed, or taken into account by the implementation.

Solution

According to playwright-core/src/browserServerImpl.ts, the underlying implementation supports passing _userDataDir for persistent contexts.

This PR adds support for these parameters in launch_server() to enable persistent context functionality when launching browser servers.

@kqvanity
Copy link

@pierorolando1

How would you connect to the ws endpoint? So far it's an unresolved issue with playwright (only Chromium based ones due to reuse of context being only supported over cdp connection)

@MichalRogowski
Copy link

MichalRogowski commented Jan 25, 2026

I've been able to connect like

   launch_server(
        humanize=True,
        fingerprint=fingerprint,
        geoip=True,
        proxy=proxy_config,
        enable_cache=True,
        persistent_context=True,
        user_data_dir=str(profile_dir),
        port=config['port'],
        ws_path=config['wsPath']
    )


and then in my playwright automation I do 
    
const browser = await firefox.connect({ wsEndpoint });

@kqvanity
Copy link

Can you access the preexisting browser contexts?

When passing user_data_dir to launch_server, it automatically opens up a new context/window, and I was wondering if I can access/reuse this one (since it's the one with passed/desired context)

@MichalRogowski
Copy link

The bigger problem for me is that user_data_dir in the launch_server approach. But I get consistent results when I run it as with Camoufox() as browser

@kqvanity
Copy link

I get consistent results when I run it as with Camoufox() as browser

Ya but I'm using the camoufox pypi module only on the server-side.

@altrof
Copy link

altrof commented Feb 2, 2026

Any updates so far? I also thought why launch_server doesn't provide arguments persistent_context and user_data_dir.

@kfirfer
Copy link

kfirfer commented Feb 15, 2026

Does the PR really fixed it and able to use persistent profile ? or its just a stubs ?

@altrof
Copy link

altrof commented Feb 15, 2026

yes, PR fixed it and able to use persistent_context with user_data_dir. I checked it locally.

@kfirfer
Copy link

kfirfer commented Feb 15, 2026

yes, PR fixed it and able to use persistent_context with user_data_dir. I checked it locally.

Thanks I confirm that it is fixed also for me

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.

5 participants