-
Notifications
You must be signed in to change notification settings - Fork 9k
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
[Feature]: Support for puppeteer-web #12022
Comments
It should be possible to execute puppeteer-core inside the extension. Is anything missing for that? |
@OrKoN As puppeteer-core has node specific dependencies like util, fs it throws error in the browser
Somehow, these node specific dependencies should be separated to make this work on a browser. |
@shivamothkuri yeah you need to perhaps exclude them when you bundle |
Do you have a test repo for this? Are you using webpack or rollup? I'd recommend using the rollup as webpack might be doing too many things. |
Also, what version do you use? |
I don't have a test repo, yet. I'm trying it on my local setup. I got an archived repo which kind of solves my issue. But, this repo is using very old version of puppeteer-core v4.0. The author has used browserify and aliasify, which don't have good updates recently and failing to modularise ES2022 code from latest puppeteer-core, like using #(hashes) for private methods/variables. So, I tried to use a older version of puppeteer-core v18.0.0. Even for this, the node dependencies are an issue. I tried to use rollup, but the number of things to exclude are never ending. And, I would face same problem when I will try to update to a newer puppeteer-core version. |
Its puppeteer-core v18.0.0 |
Please try using the latest version, there should not be many things to exclude in the latest version: all Node dependencies would be only loaded in the node runtime and there should be not much to do. In fact, puppeteer-core is used by Chrome DevTools in the browser so that should mostly working. |
Ok. Let me try with latest version and get back. Thanks |
So building something like this seems to work (main.js):
index.html
rollupconfig:
|
You need to run a browser like this: |
yes, I'm aware of this solution to use remote-debugging-port. But, I don't want my users to change the way they are opening the chrome. If we use record/replay from chrome devtools recorder, it just works. I want to build an experience like that. Do you have the source code/docs on how chrome devtools is able to replay without debugging port enabled? |
@shivamothkuri that is not possible for security reasons. |
You can use https://developer.chrome.com/docs/extensions/reference/api/debugger but it is a bit more work to write a custom transport and that API does not support modern CDP sessions that Puppeteer requires. That is not directly related to running Puppeteer in the browser though. |
@OrKoN, can you expand on "that API does not support modern CDP sessions that Puppeteer requires", please? |
@OrKoN I tried with latest puppeteer-core(22.3.0) and I'm using a custom transport for protocol from puppeteer-extension-transport . This works for puppeteer-core v13.x, but having trouble for later releases. When I tried with latest puppeteer-core version, I ger below error in the console
I have my sample extension with this error message pushed here: https://github.com/shivamothkuri/chrome-ui-recorder |
Puppeteer relies on the flat session mode https://chromedevtools.github.io/devtools-protocol/tot/Target/#method-attachToTarget (i.e., multiple sessions in one connection with sessionId used to match commands to sessions) but AFAIK chrome.debugger only supports non-flat mode meaning a different chrome.debugger API needs to be invoked to attached to each of the targets manually (that might not work well if you want to configure the target before it starts running). |
@shivamothkuri looks like in the meantime some domains have been restricted for extensions so this explains the error you are seeing. I think the only short-term solution for newer versions is to catch this command on the transport level and return a dummy response. |
This is now documented in https://pptr.dev/guides/running-puppeteer-in-extensions and https://pptr.dev/guides/running-puppeteer-in-the-browser |
Feature description
As part of this PR, you have removed support for puppeteer web and want to look at that feature soon. Could you please implement this feature? Or if there is an alternative, could you please redirect me to one.
I want to use puppeteer-web to execute puppeteer script inside my chrome extension. I see there is a way to start chrome with remote debugging enabled and use puppeteer.connect to connect via ws, but I don't feel that is a cleaner way of doing it.
The text was updated successfully, but these errors were encountered: