Skip to content

fix: allow shared playwright instance across launch calls#445

Open
siddhant-bayas wants to merge 2 commits into
CloakHQ:mainfrom
siddhant-bayas:main
Open

fix: allow shared playwright instance across launch calls#445
siddhant-bayas wants to merge 2 commits into
CloakHQ:mainfrom
siddhant-bayas:main

Conversation

@siddhant-bayas

Copy link
Copy Markdown

each launch_context_async() call spawns its own node.js driver process. calling it multiple times creates multiple processes — more memory, more cpu, more overhead. this is an api misuse that the current api silently enables.

adds optional playwright= parameter to launch(), launch_async(), launch_context(), and launch_context_async(). when provided, reuses the existing driver process instead of spawning a new one. caller owns the lifecycle — closing a context with a shared instance does not stop the playwright driver.

before:
ctx1 = await launch_context_async() ctx2 = await launch_context_async() # second node.js process

after:
async with async_playwright() as p: ctx1 = await launch_context_async(playwright=p) ctx2 = await launch_context_async(playwright=p) # shared driver

@siddhant-bayas siddhant-bayas changed the title fix: allow shared playwright instance across launch calls (#439 ) fix: allow shared playwright instance across launch calls Jul 14, 2026
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.

1 participant