Repository navigation
fix(web): launch Chromium with its sandbox on where it can start - #1621
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 48 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
|
CI on 869b879: the check job failed on one testbed web test, tests/screenshot.e2e.ts > page screenshot > should work while navigating (ENGINE_FAILURE: screenshot failed because the execution context was destroyed by a navigation; 508 of 511 passed). This head is docs-only (SECURITY.md, reference page, skill reference, one JSDoc comment), so it cannot cause a screenshot race; it reads as a timing flake in that navigation test. A re-run of the check job should clear it. |
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review (agent-run triage).
Thanks, the code is correct and well tested:
- One local launch path (
browser-connection.ts:85-92), CDP attach/provider leases/smol takeconnect()and are untouched, Firefox/WebKit untouched. - Flag read from the run env (
info.env), neverprocess.env; option > env > default on. - Real launch on macOS: default has no
--no-sandbox,E2E_CHROMIUM_SANDBOX=0adds it. 50 integration tests pass sandboxed, 338 web unit tests pass. - 11 of 15 mutations killed (default flip, env drop,
process.envread, precedence swap, chromium-only guard, validation, init resolution).
The blocker is what this does to users on Linux.
Must fix
- Docker/Linux CI users break after a patch bump. In the official
mcr.microsoft.com/playwright:v1.65.0-nobleimage, a sandboxed launch fails both as root and aspwuser("Chromium sandboxing failed!"); unsandboxed works. Same on ubuntu-2404 runners (the PR's own CI opt-outs show it), likely on most Linux containers. The changeset is a patch and says nothing about it. At minimum a minor bump with a line telling users to setE2E_CHROMIUM_SANDBOX=0. - The failure is a raw Playwright error. It surfaces as
ENGINE_FAILURE: browser launch failed: browserType.launch: Target page, context or browser has been closed ... Chromium sandboxing failed!plus a ~40-flag call log, and only hints at achromiumSandbox: falseoption, neverE2E_CHROMIUM_SANDBOX=0, which is what a CI user can actually use. Catch that one failure inacquireBrowserand throw an e2e error naming both opt-outs, without the call log. - CI docs not updated.
docs/ci/github-actions.mdx, the otherdocs/ci/*.mdxanddocs/visual-testing.mdxdon't mention the opt-out, and nobody has checked whether the documentedubuntu-latestrecipe still launches.
Should fix (structure)
- Parsing is split:
readChromiumSandboxFlag(browser-connection.ts:40) is exported only to return a lowercased string, andsurface.ts:293-300decides what it means. OneresolveChromiumSandbox(configured, env): booleanin one place, drop the export. configuredChromiumSandboxplus a mutablechromiumSandbox = true(surface.ts:312-315): one field would do; the pre-inittrueis untested (mutation tofalsesurvives).acquire(name, headed, timeoutMs, chromiumSandbox, connect?): four primitives in a row, switch to an options object.surface.tsis already 1.3k lines; ~15 of the 43 added lines are a JSDoc repeating the paragraph that also appears in web.mdx, both setup.md copies, SECURITY.md, security.mdx and the changeset. One or two lines.
Nits
cdp-attachtest edits are pointless (flag doesn't apply to attach).screenshot-caretandstalled-framehardcodefalse, so they never run sandboxed even on macOS.- Shrink each 4-line workflow comment to one line; drop the comment lines in
mcp-test-run.test.tsandartifact-path.test.ts. - Surviving mutations:
.trim()/.toLowerCase()dropped, retry recursion passing!chromiumSandbox. - Docs explain the "why" in six places; keep it in
security.mdx, link from the rest. - Red CI is
screenshot.e2e.ts > should work while navigating, a known flake unrelated to this.
For maintainers: default policy. Always on (this PR), or on for macOS/Windows and off on Linux, which is what Playwright MCP does for the same agent-browsing threat model (bundled Chromium on Linux defaults to sandbox off). That keeps dev laptops (where the keys live) protected and drops the workflow edits, most of the test churn and the Docker breakage. Also: patch vs minor, whether the env var is worth it, smol's VM --no-sandbox stays.
|
Thanks for the thorough review. The screenshot.e2e.ts failure is the known flake, confirmed unrelated: the 869b879 head is docs-only, and the same test passed on the earlier head. On the must-fix items: I will add the friendly launch-failure error naming both opt-outs, update the CI docs (github-actions, the other ci pages, visual-testing) and verify the ubuntu-latest recipe, and bump the changeset to minor with a line telling Linux and Docker users to set E2E_CHROMIUM_SANDBOX=0. I will also do the should-fix restructuring (single resolveChromiumSandbox, one field, options object for acquire, shorter JSDoc) and the nits. The default-policy question (always on, or on for macOS and Windows and off on Linux) is yours to decide; I am keeping the always-on default unless you say otherwise, since the must-fix items assume it. |
|
All addressed in f9147f3 (two commits on the PR branch):
|
There was a problem hiding this comment.
All reported issues were addressed across 21 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
View guided diff | Re-trigger cubic
Superseded by re-review of f9147f3 (automated review)
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-review of f9147f3. The minor bump, the friendly launch error, the CI docs and the single resolveChromiumSandbox are all done. You were right about the /docs/security link: it returns 200. One small round left.
Must fix
skills/e2e/references/running.md:230-247(and theplugins/e2ecopy): the skill's GitHub Actions recipe runsubuntu-latestwithoutE2E_CHROMIUM_SANDBOX: '0'. This is the workflow agents copy into user repos, so every web job built from it fails at launch once this ships. Add the env line there.
Should fix
2. Move the friendly-error mapping out of surface.ts (around line 424, with verb === 'launch' and a string match) and into BrowserConnection's local launch (browser-connection.ts around line 101). There name === 'chromium' && chromiumSandbox is already known, so you can throw the EngineError directly. The surface already rethrows EngineError as is. This shrinks surface.ts, which is already 1278 lines, and removes the untested verb guard. Removing that guard currently survives the tests.
3. The message can name an opt-out that does nothing. With web({ chromiumSandbox: true }), the option wins, so E2E_CHROMIUM_SANDBOX=0 changes nothing. Only name the env var when the option is unset, or say "unless the config sets chromiumSandbox".
4. chromiumSandbox on the surface holds the configured option before init and the resolved value after. The ?? true fallback in acquireBrowser is said never to run, but startAttempt without init reaches it. That is why artifact-path.test.ts needed an init call. Use a readonly option field plus private chromiumSandbox = true, the same pattern as headed.
5. Test gap: the relaunch recursion passing !chromiumSandbox still survives. The "relaunch fails while another caller waits" test only uses false and recurses twice, so the flip cancels itself out. A case that starts with true would kill it.
Nits
resolveChromiumSandbox:value === undefined || value === '' ||is dead code, becausevalue !== '0' && value !== 'false'already covers both.docs/reference/web.mdx:113-118still describes Playwright's "Chromium sandboxing failed!" error. Point it to the new e2e error and add a launchENGINE_FAILURErow to the Throws table.docs/visual-testing.mdx:71: limit "the Linux runners block" toubuntu-latest, the same way the github-actions page does.- The
acquireJSDoc repeats theBrowserAcquireOptions.chromiumSandboxfield doc.
Mutation run: 15 of 21 mutants were killed. The real survivors are items 2, 4 and 5 above. The web suite passes 740 tests on macOS.
Maintainer decisions (not for you)
- Always on, or off on Linux like Playwright MCP. Off on Linux would make item 1 and most of the workflow churn unnecessary.
**Release:**or**Breaking:**as the changeset opener.- Whether an explicit
chromiumSandbox: truebeatsE2E_CHROMIUM_SANDBOX=0.
This was an automated review.
|
Review round addressed as 3a0ee17 (plus 2b24558 for the visual-testing nit below). Must fix:
Should fix: Nits:
Verified: web unit suite 362/363 pass and |
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-review of 3a0ee17. CR 2 asks 1-4 and every nit are done:
- the opt-out is in both skill copies
- the friendly error now lives in
BrowserConnection.launchLocal - the message names the env var only when the option is unset
- the readonly option field is in
The precedence is option, then run env, then on, and it's tested. I reproduced the matcher's Playwright text with a real root launch inplaywright:v1.63.0-noble. CI is green and there are no em dashes.
Should fix
- The relaunch flip survivor (ask 5) is still alive. The new test that starts with
truerecurses twice, so the flip cancels out. Add a case where a waiter callsacquirewhile the relaunch'spendingis unresolved: the secondlaunchmock rejects aftersetTimeout(20), the waiter joins aftersetTimeout(0), and you assert the sandbox flags are[true, true, true]. That kills the mutant. - The friendly-error test should also assert
retryable === false. Aretryable: truemutant survives today. docs/reference/environment.mdx:E2E_CHROMIUM_SANDBOXis missing from the env var reference. Add a row:0turns the Chromium sandbox off unlessweb({ chromiumSandbox })is set.skills/e2e/references/running.md:248(and the plugins copy) andpackages/web/src/surface.ts:176link[Security](/security). That link is dead outside the docs site, and in the skill it sits in a YAML comment users copy. Usehttps://e2e.com/docs/security, assetup.mdandSECURITY.mddo.browser-connection.ts~55-73 and 129: two parallel fields,chromiumSandboxand an optionalchromiumSandboxConfigured?, hold one resolved value, and the surface always passes the second. HaveresolveChromiumSandboxreturn{ enabled, fromOption }and pass that one object. Also passoptionstolaunchLocalinstead of 5 positional args.
Nits
- The changeset says the error names "both opt-outs". That's no longer always true.
- The
acquireJSDoc says "a relaunch keeps the value the first launch used", butBrowserConnectiondoesn't enforce that. It holds only because the surface fixes the value ininit.
Open for @okwasniewski
- Always on, or off on Linux like Playwright MCP?
- Should an explicit
chromiumSandbox: truebeatE2E_CHROMIUM_SANDBOX=0? **Release:**or**Breaking:**in the changeset?- Our CI sets the opt-out everywhere, so no job ever launches with the sandbox on. Do we want one sandbox-on smoke job?
|
Done in de15327, all five asks plus the two nits.
Nits: the changeset says the error names the opt-out that applies, and the acquire JSDoc states the actual guarantee (a launch takes the value its own call passes). Left for you: always on vs off on Linux, whether explicit chromiumSandbox: true beats E2E_CHROMIUM_SANDBOX=0, Release: vs Breaking:, and the sandbox-on smoke job. Web unit suite 364/364 green with E2E_CHROMIUM_SANDBOX=0. |
There was a problem hiding this comment.
All reported issues were addressed across 9 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
|
CI note on head 86c6cf8: the only failing job is check, and it fails on an infra step, not the change. The mcp-publisher download step got HTTP 504 from the modelcontextprotocol/registry release four times in a row, then exited 22. Lint, typecheck, dead code, error codes, peer ranges, changesets, examples, and the plugin and MCP registry checks all passed, and the test job is green. A re-run of the check job should clear it. |
|
Automated review. Re-review of 86c6cf8: all five CR 3 asks are done and verified. Labeling Ready for Human Review.
Optional nits:
For maintainers to decide:
|
CR 3 asks addressed in de15327/86c6cf80
|
Thanks for the re-review, all five CR 3 asks verified and the Ready for Human Review label noted. The optional nits are left as-is for now: the placeholder in surface.ts, the JSDoc repeats, and the test-literal repetition are cosmetic, and I did not want another push to strip the label. Happy to fold any of them in if you would like them done, and the open questions (always-on vs off-on-Linux, explicit option vs env var, Release vs Breaking, a Linux sandbox-on smoke job) are yours to decide. |
86c6cf8 to
fbf2a4f
Compare
|
Rebased onto current main (d8b694f). New head fbf2a4f. All five CR 3 asks remain addressed, and the rebase kept all eight commits. The only conflicts were mechanical: upstream additions alongside our change in packages/e2e/tests/integration/mcp-test-run.test.ts and docs/ci/github-actions.mdx, resolved by keeping both sides. Verified locally: web typecheck and lint clean, web unit 364/364 with E2E_CHROMIUM_SANDBOX=0, and the e2e package typecheck clean. The one unit test that launches a real browser fails without the opt-out on a host whose sandbox cannot start, which is the friendly error this PR adds, not a regression. Ready for human review. |
|
Follow-up: the rebase dropped the first half of the new Cache the timings history section in docs/ci/github-actions.mdx, and CI caught it (docs anchor check: docs/ci.mdx links to #cache-the-timings-history). Restored in full as f30af13; the docs check chain passes locally now. Nothing else changed; the rebase note above still stands. |
There was a problem hiding this comment.
All reported issues were addressed across 52 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
|
Re-checked after the rebase onto d8b694f. Nit: Maintainer decisions unchanged: default on Linux, option vs env precedence, Release vs Breaking, a sandbox-on smoke job. This was an automated review. |
|
Thanks for the re-check. Both nits are fixed in 904f8db: the sandbox paragraph in docs/security.mdx is re-wrapped at 80 columns, and the changeset now matches the softened wording (helps contain, does not prevent sandbox escapes) with only the user-facing part, what changed and the two opt-outs. The 3 remaining Nov 8 items are maintainer calls and stay on hold. Web unit tests pass 394/395 locally; the one failure is artifact-path.test.ts, which fails the same way on the previous head because Chromium cannot start its sandbox on this Linux host. |
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
View guided diff | Re-trigger cubic
|
CI note: the two failures on this head are a flake, not this change. test (22) fails in cli-pause.test.ts (expected pause hint text, got the RUN header instead), and spec gate fails only because test (22) failed. The diff since the fully green head ddc9429 is docs only (docs/security.mdx re-wrap plus changeset wording), so nothing in this push can change CLI pause output. The previous head was green on all 28 checks. A re-run should clear it. |
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked 904f8db72 against our check at ddc9429c0. Merges cleanly into main 160cbfe7a.
The new commit only touches docs/security.mdx and .changeset/chromium-sandbox-default.md, and both nits are done:
docs/security.mdx: the sandbox paragraph is re-wrapped. No line goes past 80 columns, and the text is unchanged.- Changeset: it now matches the docs wording ("helps contain a renderer exploit ... but does not prevent sandbox escapes") and keeps to the user-facing part: what changed and the two opt-outs.
Must fix
- None.
CI
test (22)fails intests/integration/cli-pause.test.ts:294("resumes the paused test on next or rest alike"), andspec gatefails only because of it. This is not caused by this PR. The diff since the all-greenddc9429c0is docs only, and the race is in the test on main: it waits forPaused in pauses three timesand then checks right away that stdout already has theNext: e2e run --step next ...hint. That hint arrives in a later write. The other test in the file does it correctly at:165(await run.shows('Next: e2e run --step next')). A maintainer should rerun the failed jobs of thespecrun (44651191139,test (22)). The test-side fix is a separate PR.
Verified at 904f8db72:
git diff ddc9429c0 904f8db72is 2 files, +3/-4, no code.- No em or en dashes in added lines. cubic found nothing new on this commit.
|
Thanks for the re-check. Both nits are in at 904f8db (docs re-wrapped at 80 columns, changeset wording matched to the docs). Agree on test (22): the diff since the all-green ddc9429 is docs only, and the cli-pause race is in the test on main, so the rerun of spec run 44651191139 is a maintainer action. The 3 Nov items stay on hold for the maintainer call. |
On for macOS and Windows, opt-in on Linux where root, most containers and Ubuntu 23.10+ cannot start it. The option alone decides, so CI, the test env forwarding and the docs recipes need no opt-out.
|
Thanks for carrying this through so many rounds, @Varshith-Kali. I pushed a maintainer rework on top of your commits (b86f6ae) that settles the open decisions:
Please don't rebase the branch; pull before any further push. |
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
View guided diff | Re-trigger cubic
|
Merged as a06b931. Thank you @Varshith-Kali: you found the gap in #1613, wrote the fix, and stayed with it through four review rounds and as many rebases. The option, the launch path, the error and the tests are your work; the rework on top only changed the default policy. Chromium is now sandboxed by default on macOS and Windows because of this PR. |
…neOptions.ChromiumSandbox (e2e-inc/e2e#1621) (#1998)
Issue
Fixes #1613.
@e2e-dev/weblaunched Chromium withoutchromiumSandbox, so Playwright added--no-sandboxto every browser process.e2e run.What changed
web({ chromiumSandbox })sets it either way:trueon a Linux host that can sandbox,falseelsewhere.ENGINE_FAILUREthat names the option, in place of Playwright's launch call log.connect, browser providers, Firefox and WebKit are untouched.packages/web/src/browser-connection.ts:defaultChromiumSandbox(), andacquiretakes an options object.docs/reference/web.mdx,docs/security.mdx(plusjaandzh),SECURITY.md, the skill'ssetup.md.Verified
Ran it locally: yes
e2e run tests/todos.e2e.tson macOS, watching the Chromium the CLI spawned:--no-sandbox--no-sandbox, renderers start with--seatbelt-client; 7 passedweb({ chromiumSandbox: false }):--no-sandboxis back; 7 passedchromiumSandbox: trueon a Linux host that allows user namespaces. Linux CI runs the default, which is the same launch as main.