Skip to content

[world-testing] Fix Windows Unit Tests flake on event-limit test#3055

Open
VaguelySerious wants to merge 1 commit into
mainfrom
peter/fix-windows-event-limit-test
Open

[world-testing] Fix Windows Unit Tests flake on event-limit test#3055
VaguelySerious wants to merge 1 commit into
mainfrom
peter/fix-windows-event-limit-test

Conversation

@VaguelySerious

Copy link
Copy Markdown
Member

Summary

Windows Unit Tests failed on main's changeset-release PR (#3028) at the new event-limit.test.ts test (added in #2986):

FAIL test/event-limit.test.ts > fails a runaway run at the server-supplied event limit (turbo=1)
AssertionError: expected 'CORRUPTED_EVENT_LOG' to be 'MAX_EVENTS_EXCEEDED'

CORRUPTED_EVENT_LOG means the run hit ReplayDivergenceError 3+ times (REPLAY_DIVERGENCE_MAX_RETRIES) before the max-events guard could cleanly fail it.

Root cause

Every startServer() call in world-testing spawns a fresh Local World server process against the shared, untagged .workflow-data directory (no tag, no isolated dataDir). The Local World's start() defaults recoverActiveRuns to true and, when untagged, its recovery sweep lists every untagged run in that shared directory — not just the ones the current process created (see the comment in packages/world-local/src/index.ts around the isUntagged filter).

So a server spawned by one test file, starting up while another test file's run is still mid-flight, re-enqueues that foreign run into its own in-process queue and dispatches it against the same on-disk event log — racing the run's actual owner. That produces spurious ReplayDivergenceErrors under enough concurrency (the full suite, as CI runs it), which is why it reproduced on the Windows job's own head-to-head run but not on a solo re-run of the file.

Confirmed locally: running the full world-testing suite concurrently (6x in parallel, simulating CI-level file-level concurrency) reliably produced idempotency timeouts and inline-batches-debug failures before the fix, and passed cleanly 6/6 after.

Fix

Give each spawned server its own WORKFLOW_LOCAL_DATA_DIR (a unique temp dir), removing the shared state entirely. Cleaned up in onTestFinished.

Testing

  • pnpm build && npx vitest run in packages/world-testing: 3/3 files, 15/15 tests pass.
  • 6x concurrent full-suite runs (90 tests total): all pass, no flakes (previously reproduced the same failure family as CI).

Every startServer() call ran the Local World against the shared,
untagged .workflow-data directory. Since recoverActiveRuns defaults to
true, a server starting up while another test file's run was still
in-flight would list that foreign run during its startup recovery
sweep and re-enqueue it into its own queue, dispatching it against the
same on-disk event log and racing the run's actual owner. Under enough
concurrency (the full world-testing suite, as CI runs it) this landed
as an intermittent ReplayDivergenceError, observed on the Windows
Unit Tests job for the new event-limit test.

Give each spawned server its own WORKFLOW_LOCAL_DATA_DIR so no state
is shared across concurrently-running test files.
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Jul 22, 2026 4:39pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jul 22, 2026 4:39pm
example-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workbench-astro-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workbench-express-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workbench-fastify-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workbench-hono-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workbench-nestjs-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workbench-nitro-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workbench-nuxt-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workbench-sveltekit-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workbench-tanstack-start-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workbench-vite-workflow Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workflow-docs Ready Ready Preview, Comment, Open in v0 Jul 22, 2026 4:39pm
workflow-swc-playground Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workflow-tarballs Ready Ready Preview, Comment Jul 22, 2026 4:39pm
workflow-web Ready Ready Preview, Comment Jul 22, 2026 4:39pm

@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ae73058

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@workflow/world-testing Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1455 0 239 1694
✅ 💻 Local Development 1621 0 227 1848
✅ 📦 Local Production 1621 0 227 1848
✅ 🐘 Local Postgres 1621 0 227 1848
✅ 🪟 Windows 154 0 0 154
✅ 📋 Other 1020 0 212 1232
✅ vercel-multi-region 27 0 0 27
Total 7519 0 1132 8651

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 126 0 28
✅ example 126 0 28
✅ express 126 0 28
✅ fastify 126 0 28
✅ hono 126 0 28
✅ nextjs-turbopack 151 0 3
✅ nextjs-webpack 151 0 3
✅ nitro 126 0 28
✅ nuxt 126 0 28
✅ sveltekit 145 0 9
✅ vite 126 0 28
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 128 0 26
✅ express-stable 128 0 26
✅ fastify-stable 128 0 26
✅ hono-stable 128 0 26
✅ nextjs-turbopack-canary 135 0 19
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-canary 135 0 19
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 128 0 26
✅ nuxt-stable 128 0 26
✅ sveltekit-stable 147 0 7
✅ vite-stable 128 0 26
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 128 0 26
✅ express-stable 128 0 26
✅ fastify-stable 128 0 26
✅ hono-stable 128 0 26
✅ nextjs-turbopack-canary 135 0 19
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-canary 135 0 19
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 128 0 26
✅ nuxt-stable 128 0 26
✅ sveltekit-stable 147 0 7
✅ vite-stable 128 0 26
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 128 0 26
✅ express-stable 128 0 26
✅ fastify-stable 128 0 26
✅ hono-stable 128 0 26
✅ nextjs-turbopack-canary 135 0 19
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-canary 135 0 19
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 128 0 26
✅ nuxt-stable 128 0 26
✅ sveltekit-stable 147 0 7
✅ vite-stable 128 0 26
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 154 0 0
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 128 0 26
✅ e2e-local-dev-tanstack-start- 128 0 26
✅ e2e-local-postgres-nest-stable 128 0 26
✅ e2e-local-postgres-tanstack-start- 128 0 26
✅ e2e-local-prod-nest-stable 128 0 26
✅ e2e-local-prod-tanstack-start- 128 0 26
✅ e2e-vercel-prod-nest 126 0 28
✅ e2e-vercel-prod-tanstack-start 126 0 28
✅ vercel-multi-region
App Passed Failed Skipped
✅ nextjs-turbopack 27 0 0

📋 View full workflow run

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit ae73058 · Wed, 22 Jul 2026 16:50:59 GMT · run logs

Backend: vercel · app: nextjs-turbopack

Metric Scenario Best (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS step 138 (+13%) 320 🔴 (+33%) 🔻 388 🔴 (+19%) 🔻 2210 🔴 (+413%) 🔻 30
TTFS stream 114 (-26%) 💚 269 🔴 (-21%) 💚 343 🔴 (-7.0%) 589 (+27%) 🔻 30
TTFS hook + stream 267 (-13%) 486 🔴 (+5.2%) 2250 🔴 (+343%) 🔻 2297 🔴 (+270%) 🔻 30
STSO 1020 steps (1-20) 155 (-18%) 💚 286 🔴 (-2.7%) 379 🔴 (+12%) 454 🔴 (+30%) 🔻 19
STSO 1020 steps (101-120) 202 (-9.4%) 293 🔴 (-8.7%) 400 🔴 (-17%) 💚 437 🔴 (-13%) 19
STSO 1020 steps (1001-1020) 643 (+6.3%) 886 🔴 (+13%) 2185 🔴 (+151%) 🔻 2634 🔴 (+138%) 🔻 19
WO 1020 steps 485216 (-8.2%) 485216 (-8.2%) 485216 (-8.2%) 485216 (-8.2%) 1
SL stream latency 89 (-1.1%) 157 🔴 (+4.7%) 259 🔴 (+43%) 🔻 448 🔴 (+96%) 🔻 30

Best/P75/P90/P99 deltas compare against the most recent benchmark run on main at the time of this run. 🔻 flags a delta worse than +15%, 💚 one better than −15%.

Metrics — TTFS: time to first step body (in-deployment start() → first step body, deployment clocks) · STSO: step-to-step overhead (gap between consecutive step bodies) · WO: workflow overhead (whole-run time outside step bodies, in-deployment anchored) · SL: stream latency (in-deployment write → read propagation, readAt - writtenAt)

Scenarios — step: one trivial no-op step, no stream; no hooks, so the run stays in turbo mode (in-process fast path) · stream: one streaming step; no hooks, so the run stays in turbo mode (in-process fast path) · hook + stream: registers a hook before one step, which exits turbo mode (dispatch path) · 1020 steps: 1020 trivial sequential steps; STSO is measured between consecutive steps in the given step ranges, and WO is the whole-run overhead outside step bodies · stream latency: parallel reader/writer steps on a dedicated stream; SL is the in-deployment write->read propagation (readAt - writtenAt)

🔴 marks a percentile over its target (within target is left unmarked). Targets (p75/p90/p99, ms) — TTFS 200/300/600 · SL 50/60/125 · STSO (1-20) 20/30/60 · STSO (101-120) 30/45/90 · STSO (1001-1020) 40/60/120

All metrics are measured from deployment-side timestamps only. Runs are triggered by an in-deployment route that stamps the anchor (clientStart) right before start(), so the CI runner’s request and its path through api.vercel.com sit outside every measured window. TTFS = in-deployment start() → first step body (turbo uses the in-process fast path, non-turbo the dispatch path), and includes the VQS dispatch hop plus any /flow cold start. STSO/WO are measured between step bodies on the deployment. SL is measured inside the workflow (parallel reader/writer steps), so it no longer includes the api.vercel.com read path.

Cold starts are kept in the numbers on purpose — they are part of real bursty-workload latency. The workbench deployment cold-starts the /flow invocation for a large fraction of runs, inflating P75+; the Best column shows the fastest (warm-start) sample for comparison.

@VaguelySerious
VaguelySerious marked this pull request as ready for review July 22, 2026 16:40
@VaguelySerious
VaguelySerious requested review from a team and ijjk as code owners July 22, 2026 16:40
@VaguelySerious
VaguelySerious enabled auto-merge (squash) July 22, 2026 16:46

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

One cleanup/lifecycle issue found.

});
onTestFinished(() => {
proc.kill();
void rm(dataDir, { recursive: true, force: true });

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.

proc.kill() only requests termination; it does not wait for the child to exit. On Windows the Local World process may still have files in dataDir open when this rm() runs, so it can reject with EPERM/EBUSY. Because the promise is discarded, that also becomes an unhandled rejection (and the temp directory may leak), potentially replacing the original flake with a teardown flake. Could this hook be made async, await the child's exit/close after killing it, and then await rm() (ideally with maxRetries/retryDelay for Windows)?

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