Skip to content

test(e2e): fail fast when wrangler dies and upload its logs - #1320

Merged
kody-bot merged 6 commits into
mainfrom
cursor/sentry-triage-kody-cloudflare-kody-cloudflare-46-1e01
Aug 8, 2026
Merged

kody-bot merged 6 commits into
mainfrom
cursor/sentry-triage-kody-cloudflare-kody-cloudflare-46-1e01

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Aug 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

Hardens Playwright against mid-suite Wrangler/workerd exits (the ECONNREFUSED flake that blocked deploy after #1316).

Changes

  1. Fail fast — e2e/web-server-liveness.ts probes /health before each test (auto fixture on playwright-utils test). Connection refused latches the suite and throws E2eWebServerDeadError with a clear message. Auth login retries abort immediately on refused connections instead of polling for 15s.
  2. Upload logs — on 🎭 E2E job failure, CI uploads logs.local/ as e2e-wrangler-logs so the next empty [WebServer] ERROR is diagnosable.
  3. Smoke/social-login specs now import the shared test so they get the liveness check. Playwright ignores *.node.test.ts so the helper unit tests stay Vitest-only.

No restart supervisor — if wrangler dies, we surface it and keep the logs.

Risk

Low / composes — test harness + CI artifact only.

System recap — composes existing primitives (low risk)

Mode: recap · Base: main · Head: this branch

Classification: composes — Playwright harness and Validate workflow only; no runtime primitives changed.

Primitives touched

None. Diff is under e2e/, playwright.config.ts, .github/workflows/, and docs.

System map

E2E job still starts Wrangler via Playwright webServer; this PR only fails fast when that process dies and preserves its logs.

Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).

flowchart LR
	playwright["Playwright e2e suite"]:::touched
	wrangler["Wrangler webServer"]:::untouched
	artifact["CI e2e-wrangler-logs artifact"]:::touched
	playwright -->|"webServer command"| wrangler
	playwright -->|"on failure: upload logs.local"| artifact
	playwright -->|"beforeEach: /health probe"| wrangler
	classDef touched fill:#1a7f37,color:#fff
	classDef extended fill:#9a6700,color:#fff
	classDef added fill:#cf222e,color:#fff
	classDef untouched fill:#57606a,color:#fff
Loading
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes

    • E2E tests now detect unavailable web servers before each test and fail faster with clearer errors.
    • Login retries stop immediately when the test server is no longer reachable.
    • Unrelated timeout and authentication failures retain their existing handling.
  • Testing

    • Added coverage for server liveness detection and failure behavior.
  • Documentation

    • Documented server health checks, fail-fast behavior, and troubleshooting guidance.
  • Chores

    • Failed CI E2E runs now retain Wrangler logs for 14 days.

Filter Mobile Safari / content-script TypeErrors that unguardedly read
document.querySelector("meta[property='og:type']").content from global
code on the document URL (KODY-CLOUDFLARE-46). Kody never reads og:type
this way; match requires the Safari evaluating wording and a global code
frame.
Post-merge Validate on #1316 failed with Playwright ECONNREFUSED to the
local webserver (infra flake; PR CI and pre-push E2E were green). Empty
commit to re-run push Validate so production deploy can proceed.
When the Playwright webServer exits mid-suite, remaining tests were burning
CI retries on ECONNREFUSED. Probe /health before each test, abort auth retries
immediately on connection refused, and upload logs.local/ from the E2E job on
failure so the next empty [WebServer] ERROR is diagnosable.
@kentcdodds
kentcdodds marked this pull request as ready for review August 8, 2026 16:19
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@cursor[bot], you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 91b81c24-174f-48b0-a381-206c8cd5f49b

📥 Commits

Reviewing files that changed from the base of the PR and between 70c2c95 and 824c68a.

📒 Files selected for processing (1)
  • e2e/playwright-utils.ts
📝 Walkthrough

Walkthrough

The E2E suite now checks web-server health before tests, detects connection-refused failures, stops authentication retries after server death, and uploads Wrangler logs when CI fails.

Changes

E2E server liveness

Layer / File(s) Summary
Liveness detection and fail-fast state
e2e/web-server-liveness.ts, e2e/web-server-liveness.node.test.ts
Adds connection-refused detection, dead-server state tracking, /health probing, E2eWebServerDeadError, and Vitest coverage.
Playwright health checks and login retries
e2e/playwright-utils.ts, e2e/smoke.spec.ts, e2e/social-login.spec.ts
Adds an automatic health fixture, uses shared Playwright utilities, and replaces login polling with bounded retries that stop on server failure.
Wrangler log collection and documentation
.github/workflows/validate.yml, playwright.config.ts, docs/contributing/end-to-end-testing.md
Uploads logs.local/ after failed E2E jobs and documents server checks, fail-fast errors, and artifact collection.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PlaywrightTest
  participant ensureE2eWebServerAlive
  participant assertE2eWebServerAlive
  participant E2EWebServer
  participant LoginFixture
  PlaywrightTest->>ensureE2eWebServerAlive: start before each test
  ensureE2eWebServerAlive->>assertE2eWebServerAlive: check baseURL
  assertE2eWebServerAlive->>E2EWebServer: GET /health
  PlaywrightTest->>LoginFixture: authenticate
  LoginFixture->>assertE2eWebServerAlive: handle request errors
  assertE2eWebServerAlive-->>LoginFixture: throw E2eWebServerDeadError on failure
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the two main changes: fail-fast E2E behavior when Wrangler exits and Wrangler log uploads.
Description check ✅ Passed The description explains the intent, summarizes the implementation, and documents risk and system impact; it omits an explicit Testing section.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/sentry-triage-kody-cloudflare-kody-cloudflare-46-1e01

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.

@github-actions

github-actions Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-1320.kody-a99.workers.dev

Worker: kody-pr-1320
D1: kody-pr-1320-db
KV: kody-pr-1320-oauth-kv

Mocks:

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
e2e/web-server-liveness.node.test.ts (1)

56-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test the refused health probe.

Lines 56-63 pre-latch the module. assertE2eWebServerAlive therefore does not call fetch. Add a test where fetch rejects with an ECONNREFUSED error. Assert that the helper latches the server state and rejects with E2eWebServerDeadError.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/web-server-liveness.node.test.ts` around lines 56 - 63, Extend the
liveness tests around assertE2eWebServerAlive with a fresh, unlatched server URL
and a mocked fetch that rejects with an ECONNREFUSED error. Assert the helper
rejects with E2eWebServerDeadError, then verify the server is latched by
confirming a subsequent assertE2eWebServerAlive call rejects without invoking
fetch again.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/playwright-utils.ts`:
- Around line 114-146: Update the auth retry loop around the login, signup, and
fallback requests to compute the remaining budget as max(0, deadline -
Date.now()) before each request. Stop retrying immediately when no time remains,
and pass the remaining duration as the request timeout for every
page.request.post and signupOrLoginViaAuth call so no request exceeds the
15-second deadline.

---

Nitpick comments:
In `@e2e/web-server-liveness.node.test.ts`:
- Around line 56-63: Extend the liveness tests around assertE2eWebServerAlive
with a fresh, unlatched server URL and a mocked fetch that rejects with an
ECONNREFUSED error. Assert the helper rejects with E2eWebServerDeadError, then
verify the server is latched by confirming a subsequent assertE2eWebServerAlive
call rejects without invoking fetch again.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a0c56af-d102-47dc-8cb1-21dc75e49d6f

📥 Commits

Reviewing files that changed from the base of the PR and between 6f86a70 and 70c2c95.

📒 Files selected for processing (8)
  • .github/workflows/validate.yml
  • docs/contributing/end-to-end-testing.md
  • e2e/playwright-utils.ts
  • e2e/smoke.spec.ts
  • e2e/social-login.spec.ts
  • e2e/web-server-liveness.node.test.ts
  • e2e/web-server-liveness.ts
  • playwright.config.ts

Comment thread e2e/playwright-utils.ts
Address CodeRabbit feedback: each /auth attempt now uses the leftover
retry budget as its Playwright request timeout so the default 30s API
timeout cannot overrun the 15s login retry window.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 824c68a. Configure here.

Comment thread e2e/playwright-utils.ts
const loginResponse = await request.post('/auth', {
data: { email, password, mode: 'login' },
headers: { 'Content-Type': 'application/json' },
...requestTimeout,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Signup-login path doubles timeout

Medium Severity

signupOrLoginViaAuth applies the same loop remainingMs to both signup and login POSTs. On a 409 signup, the follow-up login can run for another full budget slice, so one retry iteration may exceed the 15s auth deadline the loop is meant to enforce.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 824c68a. Configure here.

@kody-bot
kody-bot merged commit fbbc885 into main Aug 8, 2026
10 checks passed
@kody-bot
kody-bot deleted the cursor/sentry-triage-kody-cloudflare-kody-cloudflare-46-1e01 branch August 8, 2026 16:34
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.

3 participants