Skip to content

fix(egress-composite): run Playwright e2e in prod and version browser cache#2145

Open
oliverlaz wants to merge 8 commits intomainfrom
fix/egress-playwright-prod-cache-key
Open

fix(egress-composite): run Playwright e2e in prod and version browser cache#2145
oliverlaz wants to merge 8 commits intomainfrom
fix/egress-playwright-prod-cache-key

Conversation

@oliverlaz
Copy link
Member

@oliverlaz oliverlaz commented Feb 27, 2026

💡 Overview

  • run @stream-io/egress-composite Playwright e2e in production mode on CI
  • bust Playwright browser cache when the Playwright version changes
  • keep browser/tooling version resolution aligned to the workspace Playwright dependency
  • initialize Sentry from a bootstrap entry so startup/import-time crashes are reported

📝 Implementation notes

  • workflow now resolves @playwright/test version and includes it in the cache key
  • Playwright version resolution uses a shell-safe command and writes to $GITHUB_OUTPUT
  • browser install steps now use yarn workspace @stream-io/egress-composite exec playwright ...
  • CI e2e execution uses yarn workspace @stream-io/egress-composite test:e2e:prod
  • Playwright config supports prod mode (PLAYWRIGHT_MODE=production) and runs preview on port 4173
  • web server timeout is set to 25000
  • egress scripts/docs were updated to keep test:e2e:prod as the canonical CI command
  • index.html now points to src/bootstrap.ts, which initializes Sentry before importing main.tsx
  • bootstrap captures app import failures (phase=bootstrap-import) and flushes before rethrowing

🎫 Ticket: https://linear.app/stream/issue/REACT-823/run-egress-composite-e2e-tests-in-production-mode

📑 Docs: N/A

Summary by CodeRabbit

  • New Features

    • Added production-mode end-to-end testing support.
  • Documentation

    • Added instructions for running Playwright tests against production builds.
  • Bug Fixes / Reliability

    • Improved app startup error-tracking initialization for production.
  • Chores

    • Updated Playwright and related dependencies.
    • Improved Playwright browser caching and CI test command to use production tests.

@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

⚠️ No Changeset found

Latest commit: 437da8a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a CI step that resolves Playwright version for cache keys; introduces a production e2e script and bumps Playwright; makes Playwright config environment-driven (dev vs production preview, ports, timeout); adds a bootstrap entry that conditionally initializes Sentry and updates index.html to load it.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/egress-composite-e2e.yml
Added Resolve Playwright version step (id playwright-version) that outputs version; updated Playwright browsers cache step/key to include ${{ steps.playwright-version.outputs.version }} and renamed cache step to "Cache Playwright browsers". Test command changed to run test:e2e:prod.
E2E Scripts & Dependencies
sample-apps/react/egress-composite/package.json
Added test:e2e:prod script (runs with PLAYWRIGHT_MODE=production); bumped @playwright/test to ^1.58.2; minor scripts formatting update.
Playwright Config
sample-apps/react/egress-composite/playwright.config.ts
Introduced PLAYWRIGHT_MODE-driven flags (runAgainstProduction, webServerCommand); conditional baseURL (ports 4173 vs 5173); webServer command now uses webServerCommand; increased webServer.timeout to 60000ms.
App Bootstrap & Entry
sample-apps/react/egress-composite/src/bootstrap.ts, sample-apps/react/egress-composite/src/main.tsx, sample-apps/react/egress-composite/index.html
Added src/bootstrap.ts that conditionally initializes Sentry in production and dynamically imports main; removed Sentry init from main.tsx; updated index.html doctype to <!doctype html> and changed script entry to /src/bootstrap.ts.
Documentation
sample-apps/react/egress-composite/README.md
Added "Run Playwright tests" subsection instructing to run yarn test:e2e:prod against the production preview.

Sequence Diagram(s)

sequenceDiagram
  participant CI as CI workflow
  participant Cache as Playwright Cache
  participant Web as Web Server (dev / preview)
  participant PW as Playwright runner
  participant App as App bootstrap

  CI->>CI: Resolve Playwright version (outputs `version`)
  CI->>Cache: Compute cache key using resolved `version`
  CI->>Web: Run `webServerCommand` (dev OR build && preview)
  Web-->>CI: Server ready on port 5173 or 4173
  CI->>PW: Invoke tests (`test:e2e` or `test:e2e:prod`) with baseURL
  PW->>Web: Execute E2E interactions against baseURL
  App->>App: bootstrap.ts conditionally init Sentry, import main
  PW-->>CI: Return test results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through CI to find my Playwright key,
browsers cached by number, ready as can be,
preview or production—I tiptoe through each door,
Sentry wakes in prod, then I import and soar,
tests nibble at URLs and leave a little glee.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main changes: running Playwright e2e tests in production mode and versioning the browser cache key.
Description check ✅ Passed The description comprehensively covers all required sections with clear overview, detailed implementation notes, and a linked ticket, following the template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/egress-playwright-prod-cache-key

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@oliverlaz oliverlaz requested a review from jdimovska February 27, 2026 14:27
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/egress-composite-e2e.yml (1)

62-63: ⚠️ Potential issue | 🟠 Major

CI is still running the default E2E script, not guaranteed production mode.

Line 63 invokes test:e2e, which does not explicitly set PLAYWRIGHT_MODE=production. If the goal is prod-mode CI, call the prod script directly.

Suggested patch
-      - name: Run Playwright tests
-        run: yarn workspace `@stream-io/egress-composite` test:e2e
+      - name: Run Playwright tests
+        run: yarn workspace `@stream-io/egress-composite` test:e2e:prod
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/egress-composite-e2e.yml around lines 62 - 63, The
workflow step "Run Playwright tests" currently invokes the package script
test:e2e without forcing production mode; update the step to either run the
production script (e.g. the package script that ensures
PLAYWRIGHT_MODE=production) or export PLAYWRIGHT_MODE=production before running
test:e2e so Playwright runs in prod mode; target the workflow step named "Run
Playwright tests" and adjust the run command to set the PLAYWRIGHT_MODE
environment variable or call the explicit prod script to guarantee
production-mode execution.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/egress-composite-e2e.yml:
- Around line 38-41: The GitHub Actions workflow fetches the Playwright version
from the `@stream-io/egress-composite` workspace but runs browser installation
commands using root-level npx playwright, causing failures since Playwright is a
devDependency only in that workspace. Update the browser installation steps
(lines 57 and 60) to use the workspace-scoped Playwright CLI by prefixing the
commands with yarn workspace `@stream-io/egress-composite` exec to ensure the
correct Playwright binary is invoked.

In `@sample-apps/react/egress-composite/playwright.config.ts`:
- Around line 59-60: Update the Playwright webServer configuration by increasing
the webServer.timeout value (the timeout property paired with webServer.command)
from 10000 to a much larger value (e.g. 120000–180000) so yarn build && yarn
preview can complete in production mode; change the timeout constant in
playwright.config.ts and re-run a cold CI with PLAYWRIGHT_MODE=production to
verify stable startup.

---

Outside diff comments:
In @.github/workflows/egress-composite-e2e.yml:
- Around line 62-63: The workflow step "Run Playwright tests" currently invokes
the package script test:e2e without forcing production mode; update the step to
either run the production script (e.g. the package script that ensures
PLAYWRIGHT_MODE=production) or export PLAYWRIGHT_MODE=production before running
test:e2e so Playwright runs in prod mode; target the workflow step named "Run
Playwright tests" and adjust the run command to set the PLAYWRIGHT_MODE
environment variable or call the explicit prod script to guarantee
production-mode execution.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d5bae28 and 3ef10cf.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • .github/workflows/egress-composite-e2e.yml
  • sample-apps/react/egress-composite/README.md
  • sample-apps/react/egress-composite/package.json
  • sample-apps/react/egress-composite/playwright.config.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
sample-apps/react/egress-composite/package.json (1)

11-12: Cross-platform compatibility concern with inline environment variable.

The PLAYWRIGHT_MODE=production syntax works on Unix/macOS but fails on Windows cmd/PowerShell. If local Windows development is a use case, consider using cross-env.

Since the CI workflow likely runs on Linux, this is acceptable if local development on Windows isn't required.

♻️ Optional fix for cross-platform support
-    "test:e2e:prod": "PLAYWRIGHT_MODE=production playwright test"
+    "test:e2e:prod": "cross-env PLAYWRIGHT_MODE=production playwright test"

Then add cross-env to devDependencies:

"cross-env": "^7.0.3"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sample-apps/react/egress-composite/package.json` around lines 11 - 12, The
npm script "test:e2e:prod" in package.json uses inline env assignment
(PLAYWRIGHT_MODE=production) which breaks on Windows; update the script to
prefix with cross-env (e.g., use cross-env PLAYWRIGHT_MODE=production playwright
test) and add "cross-env" as a devDependency (e.g., "cross-env": "^7.0.3") so
the environment variable is set cross-platform; modify the "test:e2e:prod"
script and install/declare cross-env in package.json's devDependencies to
resolve Windows compatibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@sample-apps/react/egress-composite/package.json`:
- Around line 11-12: The npm script "test:e2e:prod" in package.json uses inline
env assignment (PLAYWRIGHT_MODE=production) which breaks on Windows; update the
script to prefix with cross-env (e.g., use cross-env PLAYWRIGHT_MODE=production
playwright test) and add "cross-env" as a devDependency (e.g., "cross-env":
"^7.0.3") so the environment variable is set cross-platform; modify the
"test:e2e:prod" script and install/declare cross-env in package.json's
devDependencies to resolve Windows compatibility.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3ef10cf and 65f59e7.

📒 Files selected for processing (3)
  • sample-apps/react/egress-composite/README.md
  • sample-apps/react/egress-composite/package.json
  • sample-apps/react/egress-composite/playwright.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • sample-apps/react/egress-composite/playwright.config.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@sample-apps/react/egress-composite/src/bootstrap.ts`:
- Line 3: The environment variable name has a typo: change the reference from
VITE_EGRESS_SENTRY_DNS to VITE_EGRESS_SENTRY_DSN where used (the assignment to
sentryDsn in bootstrap.ts and any similar imports), and update the CI/deployment
workflow deploy-react-sample-apps.yml to pass the corrected
VITE_EGRESS_SENTRY_DSN and adjust the corresponding secret name to match; ensure
any documentation or other files using VITE_EGRESS_SENTRY_DNS are updated to
VITE_EGRESS_SENTRY_DSN as well so the sentryDsn variable receives the correct
DSN.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 65f59e7 and 88bfa15.

📒 Files selected for processing (4)
  • .github/workflows/egress-composite-e2e.yml
  • sample-apps/react/egress-composite/index.html
  • sample-apps/react/egress-composite/src/bootstrap.ts
  • sample-apps/react/egress-composite/src/main.tsx
💤 Files with no reviewable changes (1)
  • sample-apps/react/egress-composite/src/main.tsx

@@ -0,0 +1,32 @@
import * as Sentry from '@sentry/react';

const sentryDsn = import.meta.env.VITE_EGRESS_SENTRY_DNS;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Search for both DNS and DSN variants of the Sentry env var
rg -n "VITE_EGRESS_SENTRY_DN" --type ts --type tsx --type yaml --type json -A 2 -B 2

# Also check for .env files
fd -e env -o -e "env.*" | head -20

# Look at the full bootstrap.ts file
cat -n sample-apps/react/egress-composite/src/bootstrap.ts 2>/dev/null || echo "File not found"

Repository: GetStream/stream-video-js

Length of output: 1266


🏁 Script executed:

# Search for both DNS and DSN variants across all files
rg "VITE_EGRESS_SENTRY_DS" -n

# Check for .env files in the sample app and root
find sample-apps/react/egress-composite -name ".env*" -o -name "vite.config.*"

# Check GitHub Actions and CI configs
find .github -name "*.yml" -o -name "*.yaml" | head -10

# Search for env var definitions in CI configs
rg "VITE_EGRESS_SENTRY" -n --type yaml --type yml 2>/dev/null || rg "VITE_EGRESS_SENTRY" -n

# Check monorepo root for vite or environment setup
ls -la | grep -E "vite|env"

Repository: GetStream/stream-video-js

Length of output: 552


🏁 Script executed:

# Check the .env-example file to see what's documented
cat -n sample-apps/react/egress-composite/.env-example

# Check the deployment workflow
cat -n .github/workflows/deploy-react-sample-apps.yml | head -100

# Check the e2e workflow for test env setup
cat -n .github/workflows/egress-composite-e2e.yml | head -80

Repository: GetStream/stream-video-js

Length of output: 7090


Typo: DNS should be DSN.

Sentry uses "DSN" (Data Source Name), not "DNS" (Domain Name System). The variable name sentryDsn is correct, but the environment variable name has a typo.

This typo is already deployed in the CI workflow. Fixing it requires updating both the code and .github/workflows/deploy-react-sample-apps.yml (line 64) to use VITE_EGRESS_SENTRY_DSN instead, along with the corresponding secret name.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sample-apps/react/egress-composite/src/bootstrap.ts` at line 3, The
environment variable name has a typo: change the reference from
VITE_EGRESS_SENTRY_DNS to VITE_EGRESS_SENTRY_DSN where used (the assignment to
sentryDsn in bootstrap.ts and any similar imports), and update the CI/deployment
workflow deploy-react-sample-apps.yml to pass the corrected
VITE_EGRESS_SENTRY_DSN and adjust the corresponding secret name to match; ensure
any documentation or other files using VITE_EGRESS_SENTRY_DNS are updated to
VITE_EGRESS_SENTRY_DSN as well so the sentryDsn variable receives the correct
DSN.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
.github/workflows/egress-composite-e2e.yml (1)

56-61: ⚠️ Potential issue | 🔴 Critical

Use workspace-scoped Playwright CLI for install steps.

You resolve Playwright from @stream-io/egress-composite, but browser install commands still run via root npx playwright. If Playwright is only present in the workspace, these steps can fail or use the wrong binary.

Suggested patch
       - name: Install Playwright browsers if not cached
         if: steps.playwright-cache.outputs.cache-hit != 'true'
-        run: npx playwright install chromium
+        run: yarn workspace `@stream-io/egress-composite` exec playwright install chromium

       - name: Install Playwright system dependencies (always)
-        run: npx playwright install-deps
+        run: yarn workspace `@stream-io/egress-composite` exec playwright install-deps
#!/bin/bash
# Verify Playwright dependency location and workflow CLI scope.
# Expected:
# 1) `@playwright/test` present in workspace package.json
# 2) root package.json may not contain it
# 3) workflow currently uses root-level npx playwright commands
rg -n '"@playwright/test"' package.json sample-apps/react/egress-composite/package.json
rg -n 'run:\s*(npx playwright|yarn workspace .* exec playwright)' .github/workflows/egress-composite-e2e.yml
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/egress-composite-e2e.yml around lines 56 - 61, The
workflow runs root-level "npx playwright" which can fail if Playwright is only
installed in the workspace package; update the two steps named "Install
Playwright browsers if not cached" and "Install Playwright system dependencies
(always)" to invoke the workspace-scoped Playwright CLI for
`@stream-io/egress-composite` (e.g. replace "npx playwright install chromium" with
a workspace exec like "yarn workspace `@stream-io/egress-composite` exec
playwright install chromium" or the equivalent pnpm/npm workspace invocation,
and likewise replace "npx playwright install-deps" with the same
workspace-scoped "playwright install-deps" command) so the workflow always uses
the Playwright binary from the package that declares the dependency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/egress-composite-e2e.yml:
- Around line 56-61: The workflow runs root-level "npx playwright" which can
fail if Playwright is only installed in the workspace package; update the two
steps named "Install Playwright browsers if not cached" and "Install Playwright
system dependencies (always)" to invoke the workspace-scoped Playwright CLI for
`@stream-io/egress-composite` (e.g. replace "npx playwright install chromium" with
a workspace exec like "yarn workspace `@stream-io/egress-composite` exec
playwright install chromium" or the equivalent pnpm/npm workspace invocation,
and likewise replace "npx playwright install-deps" with the same
workspace-scoped "playwright install-deps" command) so the workflow always uses
the Playwright binary from the package that declares the dependency.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3f7d05a and 8e46e16.

📒 Files selected for processing (2)
  • .github/workflows/egress-composite-e2e.yml
  • sample-apps/react/egress-composite/playwright.config.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants