Repository navigation
feat(e2b): run Android and web targets in E2B sandboxes - #1598
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 37 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
View guided diff | Re-trigger cubic
ca7216f to
71c6fb6
Compare
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review (agent-run triage).
Thanks @tomasvarga. This is solid work. The package layout, exports, LICENSE/NOTICE and README match the other provider packages, and the tunnel tests use a real upstream server. I found no token leaks. Sandboxes are killed on every setup failure path I could find. I couldn't do a live run because I have no E2B key.
Must fix
- The "Chromium missing" error never reaches the user (
browsers.ts:57-64,:108-110).- The
echo ... >&2; exit 1runs inside a background command whose stderr is dropped. Only theexecline redirects intoCHROMIUM_LOG. - When I ran the script locally, the message went to stderr and
/tmp/e2e-chromium.logwas never created. - A template without Playwright therefore waits 60s and then fails with "Chromium did not answer through the sandbox tunnel: HTTP 5xx" and no log lines.
- Run the mkdir and find check in the foreground (
sandbox.run), andstartonly theexec.
- The
- Nothing tests that the tunnel binds to loopback only (
tunnel.ts:160). If I change'127.0.0.1'to'0.0.0.0', every test still passes, becausetunnel.test.ts:79only matches the URL string. A LAN-reachable proxy that injects the traffic token is the main risk in this design. Assertserver.address().address.
Should fix
3. Put lifecycle cleanup in one place. Today it is spread over sandbox.ts:294-351, provider.ts:110-132 and browsers.ts:102-113. Both providers do the same thing: create, open a tunnel to a fixed port, wait until ready, and on failure kill and close.
- One
acquireSandbox({ client, params, port, signal }, ready)could own both resources with a single catch, paired with arelease. - That removes
holdand theserve/connectsplit. - The tunnel doesn't depend on the started process, so it can open right after create.
sandbox.ts(351 lines) mixes concerns: the SDK adapter, env-to-connection mapping, option checks, polling, log tail and lease lifecycle. Splitting it into a client file and a lease file falls out of 3.- agent-device version skew. The sandbox installs the engine's pinned
agent-device, but the.apkinstall goes through this package's own pinned0.21.36client. With the peer range@e2e-dev/mobile >=0.11.1, the two can differ: mobile 0.12.0 pins 0.21.25. Raise the mobile floor to the version that pins 0.21.36, or keep the two in lockstep. - Untested guards. Each of these mutations survives:
- Removing
sandbox.kill()when E2B returns no traffic token (sandbox.ts:208). An orphaned sandbox on that path is untested. - Removing the 300s setup budget (
provider.ts:112). - Dropping the WebSocket upgrade's buffered
headbytes (tunnel.ts:153).
- Removing
- Docs: cut the "How the sandboxes stay private" section in
docs/integrations/e2b.mdxto one sentence.maskRequestHost, Chromium's Host check and theE2B_SANDBOX_URLmechanics are internals. Users need to know one thing: the tunnel listens on 127.0.0.1, and any local program can use it during the run. TheE2B_SANDBOX_URLrule already lives inreference/environment.mdx. - Measure "ready in about 15 to 30 seconds" or drop it. Each Android lease downloads Node, runs
npm install -g agent-deviceand boots Android (provider.ts:51-58).
Nits
- The template example uses
memoryMB: 4096, but the prose says "at least 2 GB". browsers.ts:76:Reflect.get(json ?? {}, ...)throws on a primitive JSON body. The retry hides it, but a typed narrowing reads better.- The Node tarball downloaded in the sandbox isn't checksum-verified (
provider.ts:54). - No other package has a
contributorsfield inpackage.json. - The
e2bdevDependency can go to 2.63.0.
Ran
- Package tests: 57/57 pass.
tsc, oxlint,check:peer-ranges,check:changeset-bumps,check:examples,docs:check,docs:check-errorsandcheck-dist: all clean.- The npm pack has 17 files.
- Mutations: 25 of 30 killed.
Fork CI is waiting on maintainer approval, so the build, test and spec jobs haven't run on this branch.
- One sandboxLeases().acquire creates the sandbox, opens its tunnel, and runs the provider's ready step, with a single cleanup that closes the tunnel and kills the sandbox; sandbox.ts splits into client.ts (SDK and connection) and lease.ts. - The browser provider finds Chromium in the foreground, so a template without it fails the lease with that message instead of at the start timeout. - The Node tarball the Android setup downloads is checked against its SHA-256. - Read the /json/version body with a typed check instead of Reflect.get. - Tests for the loopback bind, an upgrade's buffered bytes, a sandbox created without a traffic token, and the setup budget.
…ev to 2.63.0 0.12.6 is the first @e2e-dev/mobile release that pins agent-device 0.21.36, the version this package installs builds with.
There was a problem hiding this comment.
All reported issues were addressed across 10 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
# Conflicts: # docs/package.json # pnpm-lock.yaml # scripts/check-docs-examples.ts
…-dev/web now pins
|
[claude-opus-5-5] responding on behalf of @tomasvarga Thanks for the review. All of it is in 93b6039, 59168c0, and 69e7efd (new commits, no force-push). Must fix
Should fix Nits
Verified on this head: 62 unit tests, |
…guards for real - The Node download, checksum, and unpack run as separate commands, so under set -e a failed step stops setup instead of falling through to npm install. - find's own error no longer comes before the missing-Chromium message. - Tests: the setup budget ends a lease when it fires, the Chromium lookup's shell guard runs in bash, bad Chromium paths are refused, the checksum is the exact published one, and the upgrade test sends its bytes as the head. - Docs: say what the Android start time covers, measured at 15 to 45 seconds.
|
[claude-opus-5-5] responding on behalf of @tomasvarga Follow-ups since my last comment, all new commits:
Re-verified live on 73aca2e: Android, Chromium, and a template without Chromium failing fast. |
- A setup that hits its 300s budget now fails with what was running, not the bare timeout. - Drop envs from run(), which no caller passes, and the unused files.write mock; fix the forwarded-headers comment and the setup script's comment.
|
Automated re-review (agent-run triage) at Every ask from the last review is done:
e2b tests 66/66, typecheck clean, Optional, non-blocking
For maintainers: default |
Asks addressed, see re-review comment.
okwasniewski
left a comment
There was a problem hiding this comment.
Sorry for the delay, LGTM!
What and why
@e2e-dev/e2b: run targets in E2B sandboxes, as agreed in Official E2B integration: Android devices and web browsers in E2B sandboxes #1414.e2b(): a device provider for the mobile engine. Android 16 on E2B's publicandroid-16template, one sandbox per worker slot. The.apkis installed through agent-device, likedevice.installApp().e2bBrowsers()from@e2e-dev/e2b/web: a browser provider for the web engine. Chromium in a sandbox per worker slot, or per attempt.packages/e2b/src/tunnel.ts) adds E2B's traffic token, because the web engine connects with a CDP URL alone and agent-device's client sends no custom header. A lease holds only127.0.0.1:<port>, so the token never reaches a lease, log, or report.@e2e-dev/webpins. The docs page has the 8-line script.Issue
Fixes #1414
Verified
Ran it locally: yes
e2e runagainst the built packages: Android 16 installs Privacy Friendly 2048 from an.apk, launches it, and swipes; Chromium browses Wikipedia in worker and attempt scope, and reads a download back. No sandbox is left running after a run.agent.actstep on the same sandbox, Android first, then Chromium.e2b-e2e-live-demo.mp4
Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.