feat: support external browser + page in puppeteer options#201677
Open
Adi1231234 wants to merge 1 commit intowwebjs:mainfrom
Open
feat: support external browser + page in puppeteer options#201677Adi1231234 wants to merge 1 commit intowwebjs:mainfrom
Adi1231234 wants to merge 1 commit intowwebjs:mainfrom
Conversation
allow passing a pre-existing `browser` and `page` via `options.puppeteer` so the Client can work with a browser you already control. when both are provided, the Client skips puppeteer.launch() and uses them directly. also uses browser.process() in destroy/logout to decide cleanup: close() for launched browsers, disconnect() for connected ones.
b654043 to
ff2e280
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for passing a pre-existing
browserandpageviaoptions.puppeteer, so the Client can work with a browser you already control (e.g. Electron's built-in Chromium, or a shared browser pool).When both
browserandpageare provided, the Client skipspuppeteer.launch()/puppeteer.connect()and uses them directly. Existing behavior is unchanged when these options are not set.What changed
initialize()- newifbranch before the existingbrowserWSEndpointcheck:destroy()/logout()- usebrowser.process()to decide cleanup:process() !== null(we launched it) ->browser.close()as beforeprocess() === null(external browser) ->browser.disconnect()onlyWithout this,
browser.close()sends CDPBrowser.closewhich kills the entire external browser, not just this client's session.disconnect()only closes the WebSocket, leaving the browser running.This is the same pattern puppeteer uses internally in
Symbol.dispose.Example