Comments (4)
Yup: we extract the connect
method from puppeteer's ESM build and bundle that for use inside the browser itself. When a POST call comes in with the function body, we inject that into a specific page that sets up the puppeteer browser and page objects, and then we execute your code from within the browser's runtime. The example you listed was written minimally to illustrate that it's a pretty minimal change with regard to the interface(s).
The largest challenge you might face is if you're requiring npm packages for use inside your /function call. The easiest answer is to either:
- Compile any packages you need as part of the /function call.
- Load those dependencies from a CDN or host like unpkg.
- Migrate your function calls to be purely self-contained without any dependencies.
Happy to send over an example of what those might look like. This was done purely so we don't have to run untrusted code in the NodeJS environment, while allowing developers to utilize other modules when they aren't running the service themselves.
from browserless.
Of course! More details below:
- Each /function call creates a new browser and tab. We'll eventually expose a new API to reconnect to an existing browser so it'd be possible to have multiple functions running the browser each talking to their own respective tabs. More on that at a later date since it involves what we call a CDP-firewall, where each connected client can only see their own tabs/pages and not others.
- I don't think so... at least I'd imagine it'd be hard in a way. The way it works is that the page that "runs" the function code simply connects over websocket to Chrome's debugger URL, meaning Chrome just sees it as a remote debugging client. Since it goes through the same "flow" as puppeteer there's really no way to distinguish that it's a page from Chrome itself that's talking to another page. I'm myself not worried about it at this point.
from browserless.
Thanks for the quick reply, Joel. That was very helpful.
Is it correct to think this implementation as controlling one tab/page from another tab/page? If yes, I have a couple of follow-up questions:
- Does each call to the /function API create its own tab (for controlling another target tab)? (In particular, when session support is enabled for a browser instance, I was curious if the controlling tab is reused or newly created each time)
- Could Chromium decide in the future to disallow such connectivity/info-sharing between tabs?
from browserless.
Thanks a lot for the detailed explanations!
from browserless.
Related Issues (20)
- V2 Chrome puppeteer.connect not passing options through properly with curly brace HOT 2
- Sharing cache between docker containers HOT 1
- Migration from 1.x to 2.x: trackingId not usable? HOT 1
- Cannot launch browser with multi:2.2 HOT 4
- /scrape API - custom behavior with waitFor and dynamical loading page HOT 1
- "launch.blockAds" is not allowed HOT 4
- 2.2.0: no matching manifest for linux/arm64/v8 in the manifest list entries HOT 4
- args param and DEFAULT_LAUNCH_ARGS are ignored HOT 7
- Implement Prometheus Metrics format HOT 1
- Kill session by trackingIdnot working
- Chromium ARM64 'Request has timed out' HOT 11
- [BUG] Missing arm64 support for Docker image browserless/chrome:latest HOT 1
- No route or file found for resource GET: / HOT 3
- Request: please publish v1.61.1-puppeteer-21.4.1 docker image for arm64?
- blockAds doesn't work? Is there any way to insert custom uBlock rules into an existing docker container/image? HOT 1
- Docker arm64 was working till jan 2024 end now no docker image for arm64 HOT 1
- V2 cannot use proxy HOT 5
- SyntaxError: Invalid URL: "=wss://" inside railway service HOT 1
- Browserless Timeout 60000ms exceeded after running for 2 days HOT 2
- Unable to get free trial
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from browserless.