Skip to content

[world-local] Retry transient EPERM unlink failures on Windows - #3215

Merged
karthikscale3 merged 1 commit into
mainfrom
barba/world-local-windows-unlink-retry
Jul 30, 2026
Merged

[world-local] Retry transient EPERM unlink failures on Windows#3215
karthikscale3 merged 1 commit into
mainfrom
barba/world-local-windows-unlink-retry

Conversation

@AndrewBarba

Copy link
Copy Markdown
Contributor

Summary

run.cancel() on the local world can fail with EPERM: operation not permitted, unlink on Windows when hook cleanup races a concurrent reader. The fs layer already owns the fix — withWindowsRetry, which retries EPERM/EBUSY/EACCES with exponential backoff — but deleteJSON is the one mutation path that neither uses it nor swallows the error.

Observed failure

eve CI, test-integration (windows-latest) on vercel/eve#1387, world-local 5.0.0-beta.32 (the code is unchanged at current HEAD):

Error: EPERM: operation not permitted, unlink 'D:\a\eve\eve\packages\eve\.eve\.workflow-data\vitest-3\hooks\hook_01KYT1T0ZH4J57043XC0GRBYV0.vitest-3.json'
 ❯ deleteJSON            world-local/src/fs.ts:461
 ❯ deleteAllHooksForRun  world-local/src/storage/hooks-storage.ts:378
 ❯ createImpl            world-local/src/storage/events-storage.ts:1325
 ❯ e.cancel              (run cancellation)

Job: https://github.com/vercel/eve/actions/runs/30566760759/job/90953098171

The consuming test's assertions had all passed; a cleanup run.cancel() threw because deleteAllHooksForRun unlinked a hook JSON file while another handle (hook polling reading the same file) briefly held it open. On POSIX that unlink succeeds; on Windows an open handle is a share violation and unlink throws EPERM (errno -4048).

Why deleteJSON specifically

The write pipeline consistently guards the equivalent operations — withWindowsRetry(() => fs.rename(...)) (fs.ts:415), withWindowsRetry(() => fs.unlink(tempPath), 3) (fs.ts:422, 500), withWindowsRetry(() => fs.link(...)) (fs.ts:489, 527) — and every other direct fs.unlink in the package swallows failures (helpers.ts:323, legacy.ts:71, events-storage.ts:2186, index.ts:222). deleteJSON is the only unlink that both skips the retry and propagates, and it sits under run cancellation, so a transient share violation surfaces as a failed cancel. Beyond CI, a real run.cancel() on a Windows dev machine hits the same race.

Change

  • Wrap deleteJSON's unlink in withWindowsRetry. ENOENT is not in the retryable set, so the existing already-deleted tolerance still short-circuits.
  • Tests: delete + already-gone tolerance, non-ENOENT propagation, and the Windows retry path (module re-imported with process.platform stubbed to win32, unlink rejecting EPERM twice before succeeding).
  • Changeset: @workflow/world-local patch.

Testing

  • pnpm --filter @workflow/world-local test — 493/493
  • pnpm --filter @workflow/world-local exec tsc --noEmit
  • biome check clean on the touched files

deleteJSON was the one mutation path in the fs layer that neither used
withWindowsRetry nor swallowed unlink errors. On Windows, unlink fails
with a share-violation EPERM while a concurrent reader briefly holds
the file open — hook polling races deleteAllHooksForRun by design — so
a transient EPERM surfaced as a failed operation, e.g. a failed
run.cancel().

Wrap the unlink in withWindowsRetry, matching the rename/link/unlink
guards the write pipeline already has. ENOENT is not in the retryable
set, so the already-deleted tolerance still short-circuits.

Signed-off-by: Andrew Barba <barba@hey.com>
@vercel

vercel Bot commented Jul 30, 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 Jul 30, 2026 6:53pm
example-nextjs-workflow-webpack Ready Ready Preview Jul 30, 2026 6:53pm
example-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workbench-astro-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workbench-express-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workbench-fastify-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workbench-hono-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workbench-nestjs-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workbench-nitro-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workbench-nuxt-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workbench-sveltekit-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workbench-tanstack-start-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workbench-vite-workflow Ready Ready Preview Jul 30, 2026 6:53pm
workflow-docs Ready Ready Preview, v0 Jul 30, 2026 6:53pm
workflow-swc-playground Ready Ready Preview Jul 30, 2026 6:53pm
workflow-tarballs Ready Ready Preview Jul 30, 2026 6:53pm
workflow-web Ready Ready Preview Jul 30, 2026 6:53pm

@AndrewBarba
AndrewBarba requested review from a team and ijjk as code owners July 30, 2026 18:49
@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c294ef9

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

This PR includes changesets to release 18 packages
Name Type
@workflow/world-local Patch
@workflow/cli Patch
@workflow/core Patch
@workflow/vitest Patch
@workflow/web Patch
@workflow/world-postgres Patch
workflow Patch
@workflow/world-testing Patch
@workflow/builders Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/web-shared Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
@workflow/nuxt 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 30, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit c294ef9 · Thu, 30 Jul 2026 19:12:45 GMT · run logs

Backend: vercel · app: nextjs-turbopack

Metric Scenario Best (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS step 1280 (+479%) 🔻 1414 🔴 (+33%) 🔻 1429 🔴 (+30%) 🔻 1884 🔴 (+23%) 🔻 30
TTFS stream 272 (+20%) 🔻 1378 🔴 (+42%) 🔻 1421 🔴 (+38%) 🔻 1523 🔴 (+39%) 🔻 30
TTFS hook + stream 1499 (+256%) 🔻 1564 🔴 (+29%) 🔻 1628 🔴 (+30%) 🔻 1710 🔴 (+19%) 🔻 30
STSO 1020 steps (1-20) 182 (+2.8%) 320 🔴 (+8.5%) 448 🔴 (+32%) 🔻 716 🔴 (+76%) 🔻 19
STSO 1020 steps (101-120) 185 (-12%) 266 🔴 (-23%) 💚 322 🔴 (-23%) 💚 1155 🔴 (+3.7%) 19
STSO 1020 steps (1001-1020) 517 (-1.9%) 591 🔴 (+3.5%) 653 🔴 (-2.5%) 660 🔴 (-6.9%) 19
WO 1020 steps 413060 (-2.1%) 413060 (-2.1%) 413060 (-2.1%) 413060 (-2.1%) 1
SL stream latency 101 (+19%) 🔻 161 🔴 (+24%) 🔻 408 🔴 (+146%) 🔻 3646 🔴 (+907%) 🔻 30
SO stream overhead (text) 117 (-2.5%) 189 (-17%) 💚 214 (-18%) 💚 476 (+34%) 🔻 30
SO stream overhead (structured) 111 (-11%) 169 (-32%) 💚 199 (-38%) 💚 235 (-44%) 💚 30
ℹ️ Metric definitions & methodology

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) · SO: stream overhead (end-to-end write+consume time beyond the modelled generation window)

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) · stream overhead (text): writer streams 300 variable-length text token deltas paced at 100/s for 3s (a haiku-size LLM's token throughput) while a parallel reader drains the whole stream; SO is the end-to-end write+consume time beyond the 3s generation window (overhead/backpressure) · stream overhead (structured): same workload as stream overhead (text), but each delta is an AI-SDK-style structured object ({ type: 'text-delta', id, text }) instead of a raw string, so the SO gap vs the text scenario is the added serialization cost

🔴 marks a percentile over its target (within target is left unmarked). Targets (p75/p90/p99, ms) — TTFS 200/300/600 · SL 50/60/125 · SO 250/500/1000 · 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.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

E2E Test Summary

Summary
Passed Failed Skipped Total
✅ ▲ Vercel Production 1455 0 239 1694
✅ 💻 Local Development 1467 0 227 1694
✅ 📦 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 7365 0 1132 8497
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
✅ 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

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

No blocking findings. This reuses the existing Windows-only retry policy for deleteJSON, preserves ENOENT tolerance and permanent-error propagation, and adds focused coverage for the transient EPERM path.

@AndrewBarba
AndrewBarba enabled auto-merge (squash) July 30, 2026 19:05
@karthikscale3
karthikscale3 disabled auto-merge July 30, 2026 19:21
@karthikscale3
karthikscale3 merged commit f05f642 into main Jul 30, 2026
170 of 174 checks passed
@karthikscale3
karthikscale3 deleted the barba/world-local-windows-unlink-retry branch July 30, 2026 19:23
github-actions Bot added a commit that referenced this pull request Jul 30, 2026
deleteJSON was the one mutation path in the fs layer that neither used
withWindowsRetry nor swallowed unlink errors. On Windows, unlink fails
with a share-violation EPERM while a concurrent reader briefly holds
the file open — hook polling races deleteAllHooksForRun by design — so
a transient EPERM surfaced as a failed operation, e.g. a failed
run.cancel().

Wrap the unlink in withWindowsRetry, matching the rename/link/unlink
guards the write pipeline already has. ENOENT is not in the retryable
set, so the already-deleted tolerance still short-circuits.

Signed-off-by: Andrew Barba <barba@hey.com>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #3221. Merge conflicts were resolved by AI — please review carefully. (backport job run)

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