Skip to content

Add Puppeteer support for Worker JavaScript - #148

Open
scuffi wants to merge 1 commit into
mainfrom
computer/puppeteer-plugin
Open

scuffi wants to merge 1 commit into
mainfrom
computer/puppeteer-plugin

Conversation

@scuffi

@scuffi scuffi commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

This adds a public Puppeteer plugin for Computer's Worker JavaScript backend. The plugin bundles Cloudflare's Worker-compatible Puppeteer client, connects it to a Browser Run binding, and keeps Browser and Page objects inside each isolated execution.

It exposes bound launch() and withBrowser() helpers, keeps plugin bindings separate from caller environment values, and closes connection-bound browser sessions when work completes or an execution is disposed.

Usage

Register the plugin on the backend, then import Puppeteer from code executed by Computer:

import { Workspace } from "@cloudflare/computer";
import { WorkerJavaScriptBackend } from "@cloudflare/computer/backends/worker-javascript";
import { puppeteer } from "@cloudflare/computer/plugins/puppeteer";

const workspace = new Workspace({
  storage: ctx.storage,
  backends: [new WorkerJavaScriptBackend({
    loader: env.LOADER,
    plugins: [puppeteer({ browser: env.BROWSER })],
  })],
});

using execution = await workspace.runtime.exec(`
  import { withBrowser } from "@cloudflare/puppeteer";

  export default ({ url }) => withBrowser(async (browser) => {
    const page = await browser.newPage();
    await page.goto(url);
    return { title: await page.title() };
  });
`, { input: { url: "https://example.com" } });

const result = await execution.result();

Browser rendering example

The new self-hosted example accepts a URL and demonstrates scraping, screenshots, page information, and durable browser artifacts. Its research action writes report.md, page.json, and screenshot.png to one Workspace directory from a single isolated execution.

The package and architecture documentation cover Browser Run setup, lifecycle, limits, plugin authoring, and the authority granted to browser-enabled backends.


Devin Review

@changeset-bot

changeset-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

馃 Changeset detected

Latest commit: 27c19b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@cloudflare/computer Minor
@cloudflare/dofs Minor
@cloudflare/computer-rpc Minor
@cloudflare/computerd Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your interest in Cloudflare Computer.

This repository does not accept unsolicited pull requests. Please use one of the accepted contribution paths instead:

If a maintainer asked you to open this pull request, they can add the allow-pr label and reopen it.

@github-actions github-actions Bot closed this Sep 17, 2026
@scuffi scuffi added the allow-pr Allow a PR to remain open. label Sep 17, 2026
@scuffi scuffi reopened this Sep 17, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@scuffi
scuffi force-pushed the computer/puppeteer-plugin branch from d14c26a to 21a34da Compare September 17, 2026 15:33

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

Devin Review found 0 new potential issues.

Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Sep 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@cloudflare/computer@148

commit: 27c19b1

@scuffi
scuffi force-pushed the computer/puppeteer-plugin branch from 21a34da to 6aaabd9 Compare September 17, 2026 15:42
devin-ai-integration[bot]

This comment was marked as resolved.

@scuffi
scuffi force-pushed the computer/puppeteer-plugin branch from 6aaabd9 to 7951b3d Compare September 17, 2026 17:04
devin-ai-integration[bot]

This comment was marked as resolved.

Install Cloudflare Puppeteer as a configured Worker JavaScript
module and pass the Browser Run binding through the plugin authority
boundary. Bound lifecycle helpers keep browser objects inside each
isolated execution and close connection-bound sessions reliably.

Add a self-hosted browser example that scrapes pages and persists
Markdown, JSON, and screenshot artifacts in the durable Workspace.
Document setup, security, limits, packaging, and custom plugin
authoring.
@scuffi
scuffi force-pushed the computer/puppeteer-plugin branch from 7951b3d to 27c19b1 Compare September 17, 2026 18:02
@aron-cf

aron-cf commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

This is awesome, I'd love to keep worker shell backend in similar parity with the js one. What do you think to adding a browser CLI tool that takes a pupetteer flag or something.

browser puppeteer --url http://example.com run.js
browser puppeteer --url <url> --stdin <run.js

Where run.js is has a global browser instance:

export default async ({ url, browser }) => {
    const page = await browser.newPage();
    await page.goto(url);
    return { title: await page.title() };
});

@aron-cf aron-cf closed this Sep 18, 2026
@aron-cf aron-cf reopened this Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-pr Allow a PR to remain open.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants