Skip to content

Clean up validate output noise: seed e2e KV icons, silence third-party warnings, fix leaky test spies - #721

Merged
kody-bot merged 3 commits into
mainfrom
cursor/clean-validate-log-noise-b0fb
Jul 11, 2026
Merged

kody-bot merged 3 commits into
mainfrom
cursor/clean-validate-log-noise-b0fb

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 11, 2026 •

Copy link
Copy Markdown
Owner

Why

The main validate CI log was full of noise that made real failures hard to spot: ~47 community-icon-load-failed error lines per e2e run, 28 workerd WebSocket-disconnect exception dumps, 28 wrangler "Using secrets defined in" lines, broken third-party sourcemap warnings, Node ExperimentalWarning: localStorage lines, leaked usage-rollup-failed / audit-event output from tests, workerd uncaught exception storage.sql dumps, and an esbuild import-is-undefined warning. This PR eliminates every one of those sources — no failures or warnings remain in the validate output beyond genuine test results.

What changed

e2e seeding

  • e2e/kv-utils.ts (new): seeds a community snapshot (with a minimal valid SVG icon) into the e2e KV store via wrangler kv key put --local.
  • e2e/d1-utils.ts: every seeded community listing now also seeds its KV snapshot, so icon requests render a real PNG instead of logging community-icon-load-failed on every community page view.

Dependency upgrades

  • @cloudflare/vitest-pool-workers 0.14.x → 0.17.0 and wrangler → 4.106.0. The new pool version ignores the harmless WebSocket peer disconnected workerd teardown exception that printed 28 stack dumps per run.

Vitest / wrangler config

  • vitest-shared.ts, vitest.config.ts: set Vite logLevel: 'error' so broken third-party sourcemap warnings (@modelcontextprotocol/sdk, cron-schedule ship sourcemaps pointing at unpublished sources) no longer print; add execArgv: ['--disable-warning=ExperimentalWarning'] so msw's typeof localStorage probe stops tripping Node 26's experimental-localStorage warning in every fork.
  • vitest.workers.config.ts: default WRANGLER_LOG=warn so the pool's per-file config reads stop printing "Using secrets defined in packages/worker/.env" 28 times.

Log-level corrections (production code)

  • cloudflare-email.ts: skipped-send logging (cloudflare-email-unconfigured etc.) downgraded from console.warn to console.info — callers decide whether a skipped send is a problem (the verification flow throws in production), so an unconfigured client in dev/e2e is informational.
  • email-verification.ts: email-verification-send-skipped likewise warn → info; that branch only exists on non-production runtimes.
  • module-graph.ts: read fetch off the user module reflectively (Reflect.get) so esbuild stops emitting an import-is-undefined warning for every app without a named fetch export. Behavior is unchanged.

Leaky tests fixed

  • package-service.node.test.ts: the global mockReset: true restored the recordUsage spy's real implementation before each test, so the real rollup ran against the stub env and logged usage-rollup-failed. Re-stub per test in beforeEach.
  • auth-handler.node.test.ts: stub logAuditEvent (it was fire-and-forget void-ed, resolving after spies were restored and leaking audit-event lines to stdout); assert the email-skip logs on consoleInfo.
  • cloudflare-email.node.test.ts, account-resend-verification.node.test.ts: assert on the shared consoleInfo/consoleWarn spies instead of ad-hoc vi.spyOn mocks that clashed with the global console guard.
  • storage-runner.workers.test.ts: intentionally-failing read-only SQL queries now run via runInDurableObject instead of the test RPC stub — rejections crossing the RPC surface printed duplicate uncaught exception storage.sql dumps inside workerd.
System recap — extends existing primitives (medium risk, log-level only)

Mode: recap · Base: main @ 9f74862c · Head: 7227c04b

Classification: extends — three primitives get behavior-neutral tweaks (two log-level downgrades, one reflective property read); everything else is test/tooling config. No contracts, schemas, or routes change.

Primitives touched

Primitive Group Impact
email assistant extends — skipped-send log downgraded warn → info in cloudflare-email.ts
app-sessions auth extends — email-verification-send-skipped log downgraded warn → info
package-runtime runtime extends — app entrypoint reads fetch via Reflect.get (silences esbuild warning, same behavior)
community-listings assistant composes — e2e seeding now writes the KV snapshot the icon handler already expects

System map

E2E seeding now writes both the D1 listing row and its KV snapshot so the existing icon pipeline succeeds instead of logging errors.

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
	e2eSeed["e2e seeding<br/>(test tooling)"]:::touched
	communityListings["community-listings<br/>Community package listings"]:::touched
	bundleKv["bundle-artifacts-kv<br/>Bundle artifacts KV"]:::untouched
	email["email<br/>Email"]:::extended
	appSessions["app-sessions<br/>Browser sessions"]:::extended
	packageRuntime["package-runtime<br/>Package runtime"]:::extended
	e2eSeed -->|"seed listing row + KV snapshot"| communityListings
	communityListings -->|"community snapshot key"| bundleKv
	email -->|"skipped-send log warn→info"| appSessions
	packageRuntime -->|"Reflect.get(userModule, 'fetch')"| packageRuntime
	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

Verification

  • ✅ npm run validate — full green run; remaining local-only lines (DEP0205, workerd shutdown getCaughtExceptionAsKj) verified absent from CI logs of prior runs.
  • ✅ Pre-push hook e2e run: 13/13 Playwright specs passed.
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility when loading application request handlers.
    • Refined read-only storage error handling for more consistent behavior.
  • Chores
    • Updated development and testing tools (including Vitest/Vite/Wrangler versions and log-level tuning).
    • Reduced unnecessary warning and diagnostic output during local and automated test runs.
    • Improved end-to-end test setup for community icons and snapshots.
  • Logging
    • Skipped email sends in non-production environments are now reported as informational messages instead of warnings.
    • Updated related tests to match the new info-level logging behavior.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 815f5fb6-284b-4630-943b-b066007d7785

📥 Commits

Reviewing files that changed from the base of the PR and between 7227c04 and 0b8ab25.

📒 Files selected for processing (4)
  • packages/worker/src/app/handlers/account-profile.node.test.ts
  • packages/worker/src/app/handlers/account-resend-verification.node.test.ts
  • packages/worker/src/app/handlers/auth-provider.node.test.ts
  • packages/worker/src/app/handlers/two-factor.node.test.ts

📝 Walkthrough

Walkthrough

The PR adds E2E KV snapshot seeding, changes skipped email logging from warning to info, updates runtime-related tests, and adjusts Vitest, Wrangler, and Cloudflare tooling configuration.

Changes

E2E community snapshot seeding

Layer / File(s) Summary
Seed community listing and KV snapshot
e2e/d1-utils.ts, e2e/kv-utils.ts
E2E community fixtures reuse a pinned commit and write an icon-bearing CommunitySnapshot to BUNDLE_ARTIFACTS_KV through Wrangler.

Skipped email logging

Layer / File(s) Summary
Change skipped-send logging and assertions
packages/worker/src/app/email-*, packages/worker/src/app/handlers/*test.ts
Non-production skipped sends use console.info; tests assert info-level events, masked payloads, warning-level network failures, and isolated audit logging.

Runtime and test behavior

Layer / File(s) Summary
Update handler lookup and test execution
packages/worker/src/package-runtime/*, packages/worker/src/storage-runner.workers.test.ts
Generated entrypoints use reflective fetch lookup, usage spies reset per test, and read-only SQL failures are asserted inside the Durable Object.

Test runner configuration

Layer / File(s) Summary
Configure test logging and dependencies
vitest-shared.ts, vitest.config.ts, vitest.workers.config.ts, package.json
Vitest logging and Node warning settings are updated, Wrangler logging defaults to warn, and Cloudflare tooling versions are bumped.

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

Sequence Diagram(s)

sequenceDiagram
  participant E2E as d1-utils.ts
  participant Helper as seedCommunitySnapshotInE2eKv
  participant Wrangler as wrangler-env.ts
  participant KV as BUNDLE_ARTIFACTS_KV
  E2E->>Helper: seed listingId and pinnedCommit
  Helper->>Wrangler: execute kv key put
  Wrangler->>KV: write CommunitySnapshot JSON
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the PR’s main themes: reducing validate noise via e2e KV seeding, log suppression, and test spy fixes.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/clean-validate-log-noise-b0fb

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.

@kody-bot
kody-bot marked this pull request as ready for review July 11, 2026 03:52
@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

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

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

Mocks:

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