43c28b15fb
Supersedes #1698 (claimed via `/sdk claim` by @mishushakov). **Please close #1698 in favour of this PR** — I have no write access to close it myself. This is a straight clone: the commit `f65f602` from #1698 is applied here unmodified (original authorship and the `Co-authored-by: Mish Ushakov` trailer preserved), with `origin/main` merged in so the branch is current — `main` had moved one commit ahead (#1693), which touches none of the two files in this PR. The diff against `main` is identical to the original: `.github/workflows/js_sdk_tests.yml` and `packages/js-sdk/package.json`. Per the claim instructions, nothing was reviewed or changed. The original description follows, verbatim. --- Closes [SDK-339](https://linear.app/e2b/issue/SDK-339/js-sdk-node-ci-legs-spend-most-of-their-time-in-playwright-install). Related: [SDK-292](https://linear.app/e2b/issue/SDK-292/run-the-full-js-sdk-unit-test-suite-in-a-browser), which introduced the `browser` project this install serves. ## Problem `packages/js-sdk/package.json` had a `pretest` hook running `npx playwright install --with-deps chromium`. `--with-deps` shells out to apt on Linux, and to a DISM Media Foundation enable on Windows, on **every** invocation — regardless of whether the workflow's Playwright browser cache hit. On one `Test JS SDK` run that hook was 90% of the Node leg: | leg | step | time | | --- | --- | --- | | node / ubuntu-22.04 | `Run Node tests` total | 23m21s | | | ↳ `pretest` (`--with-deps`) | **20m57s** | | | ↳ `vitest run` (101 files, 100 passed) | 2m23s | | node / windows-latest | `pretest` DISM Media Foundation enable | 4m31s | The browser cache worked fine (`Cache hit for: playwright-Linux-1.55.1`, restored in 3s). The time went to apt: `apt-get update` 1m42s, then 18.4 MB fetched in 18m59s at 16.1 kB/s off a stalling Azure Ubuntu mirror (`fonts-wqy-zenhei` alone stalled 7m49s). The mirror stall is transient; being on that path at all is the structural problem. Every shared library Chromium needs (`libnss3`, `libgbm1`, `libdrm2`, `libcairo2`, `xvfb`, …) was already `already the newest version` on the runner image — the only 9 new packages were CJK/Cyrillic fonts (`fonts-wqy-zenhei`, `fonts-ipafont-gothic`, `xfonts-*`) that the single headless `browser` test never renders. For comparison, in the same run the bun (2m44s), deno (2m41s) and cloudflare (2m1s) legs run the same test code with no Playwright `pretest`. ## Change - `packages/js-sdk/package.json`: replace the `pretest` hook with an explicit `playwright:install` script (`playwright install chromium`, no `--with-deps`). - `.github/workflows/js_sdk_tests.yml`: run it as its own step gated on `matrix.runtime == 'node'`, right after the existing browser-cache step, with a comment recording why `--with-deps` is omitted. Moving it out of `pretest` also keeps it off every local `pnpm test`, including for contributors who never touch the browser project. ## Usage CI installs the browser as a distinct, cache-backed step: ```yaml - name: Install Playwright Chromium if: matrix.runtime == 'node' run: pnpm run playwright:install ``` Locally, the `browser` project needs Chromium once per Playwright version: ```bash cd packages/js-sdk pnpm run playwright:install # ~7s cold, ~0.8s once installed pnpm test ``` Without it, the `browser` project fails with Playwright's own "Executable doesn't exist … run `playwright install`" message; the other projects (`unit`, `template`, `connectionConfig`) are unaffected. ## Verification Run on this branch with no prior Playwright deps installed on the machine: - `pnpm run playwright:install`: 6.5s cold (Chromium headless shell + ffmpeg, no apt), 0.78s as a no-op afterwards. - `pnpm exec vitest run --project browser`: 1 passed. Chromium launches and drives a real sandbox without any `--with-deps` packages, confirming the fonts and libs weren't load-bearing. - `pnpm build` + full `pnpm test`: 101 files, 99 passed / 1 skipped in 2m34s. The one failure is `tests/sandbox/network.test.ts > injected header is reflected by the httpbin sidecar`, which fails with `404: template 'httpbin' not found` — it needs a prebuilt `httpbin` template that this agent's API key doesn't have, unrelated to this change. - `pnpm run format`, `pnpm run lint`, `pnpm run typecheck` clean for `packages/js-sdk` (the recursive root scripts fail only in `packages/python-sdk`, where `uv` isn't installed in this environment). - `pnpm run check-deps` (knip) reports no new findings; `playwright` is still resolved as a used devDependency through the new script. No changeset: this touches only dev tooling and CI, with no change to published behavior (the `pretest`/`playwright:install` scripts are inert for consumers of the package). The commit that originally added the hook, #977, likewise shipped without one. <div><a href="https://cursor.com/agents/bc-b8c7df94-5129-496b-ae9f-0c4cb552773a?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/automations/3b1a5376-9bd3-11f1-ba66-0e7d0216e441"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Mish Ushakov <mishushakov@users.noreply.github.com>