Skip to content

[miniflare] Use polling watcher for dev registry on Windows#13659

Merged
petebacondarwin merged 1 commit into
mainfrom
fix/dev-registry-windows-polling
Apr 24, 2026
Merged

[miniflare] Use polling watcher for dev registry on Windows#13659
petebacondarwin merged 1 commit into
mainfrom
fix/dev-registry-windows-polling

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Fixes the flaky fixtures/dev-registry/tests/dev-registry.test.ts:959 assertion that has been failing intermittently on Windows CI (e.g. this run).

Root cause

The filesystem-based dev registry uses chokidar with default settings to watch ~/.wrangler/registry/. On Windows, chokidar defaults to fs.watch (backed by ReadDirectoryChangesW), which is known to drop or delay create events for files added shortly after the watcher attaches — especially under CI virtualization.

The getPlatformProxy → wrangler/vite dev test suite is uniquely exposed to this because, unlike the other suites in the file, it attaches its watcher in-process first, then spawns a subprocess that writes the peer worker's registry file. Every other suite spawns both processes as subprocesses, so by the time the second process's watcher attaches, the file already exists on disk and chokidar's initial directory scan reliably picks it up.

When the add event is dropped, the platform proxy never learns of the new worker until the 30s heartbeat touches mtime — far beyond the test's 10s waitForTimeout. All subsequent env.WORKER_ENTRYPOINT_WITH_ASSETS.fetch() calls return the "not found" 503 and the test times out.

Fix

  • Pass { usePolling: process.platform === "win32", interval: 100 } to the chokidar watcher in packages/miniflare/src/shared/dev-registry.ts. Polling sidesteps the dropped-event problem; the registry directory is tiny so the cost is negligible. Non-Windows platforms continue to use the efficient native backend. There's existing precedent for this pattern in packages/vite-plugin-cloudflare/playground/vitest-setup.ts.
  • Bump the fixture test's waitForTimeout from 10s to 20s as defense-in-depth on slow Windows CI runners.

Verification

  • pnpm --filter @fixture/dev-registry test:ci → 23/23 passed locally on macOS (polling is disabled there, so this confirms no regression on the native-backend path).
  • Windows behaviour will be validated by the CI job on this PR across multiple runs.

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal reliability fix, no user-facing API change.

A picture of a cute animal (not mandatory, but encouraged)


Open in Devin Review

On Windows, chokidar's default `fs.watch` backend (`ReadDirectoryChangesW`)
frequently drops or delays create events for files added shortly after
the watcher attaches — especially under CI virtualization. The
in-process `getPlatformProxy` scenario is uniquely exposed to this
because it attaches its watcher before the partner Vite/Wrangler
subprocess writes its registry file, so a missed event means the
external-service binding never resolves until the 30-second heartbeat.

Switch the dev registry's chokidar watcher to polling mode on Windows
so cross-process worker registrations are observed reliably, and bump
the fixture test's `waitForTimeout` to 20s as defense-in-depth on slow
Windows CI runners.

Fixes the flaky `fixtures/dev-registry/tests/dev-registry.test.ts:959`
assertion.
@changeset-bot

changeset-bot Bot commented Apr 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7880d61

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

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-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Apr 24, 2026
@workers-devprod workers-devprod requested review from a team and vicb and removed request for a team April 24, 2026 08:07
@workers-devprod

workers-devprod commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@github-actions

Copy link
Copy Markdown
Contributor

Changeset Review

File Reviewed: .changeset/dev-registry-windows-polling.md

All changesets look good

Review Summary

Criteria Status Notes
Version Type patch for miniflare is appropriate - this is a reliability/bug fix
Changelog Quality Excellent description with detailed explanation of the Windows fs.watch issue and the polling solution
Markdown Headers No h1/h2/h3 headers found
Analytics No analytics collection mentioned
Dependabot Not a dependabot changeset
Experimental Features Not an experimental feature

Details

The changeset provides:

  • Clear, imperative title describing the fix
  • Comprehensive explanation of the root cause (chokidar default settings on Windows using fs.watch/ReadDirectoryChangesW which drops/delayed events)
  • Description of the solution (polling mode on Windows with 100ms interval)
  • Note that non-Windows platforms continue using native filesystem events

The description is technical but accessible, explaining both the problem and solution effectively for changelog readers.

@ask-bonk

ask-bonk Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

The changes are straightforward and well-motivated. Let me verify there are no other concerns:

  1. dev-registry.ts change: Adds usePolling: process.platform === "win32" and interval: 100 to chokidar's watch() call. This is a targeted, well-commented fix. The interval option is only meaningful when usePolling is true, and chokidar ignores it otherwise, so no concern about non-Windows platforms.

  2. Test timeout bump: waitForTimeout from 10s to 20s — reasonable defense-in-depth for slow CI.

  3. Changeset: Properly scoped to miniflare as a patch, with a clear description.

  4. Precedent: The vite-plugin playground uses the same pattern (usePolling: true, interval: 100) at packages/vite-plugin-cloudflare/playground/vitest-setup.ts:258, though unconditionally rather than gated on Windows.

Everything here is clean — the root cause analysis is sound, the fix is minimal and targeted, and there are no logic bugs, security issues, or backward compatibility concerns.

LGTM

github run

@petebacondarwin petebacondarwin added ci:no-changeset-required Skip pull request checks for a valid changeset ci-flake Applied to PRs addressing CI flakiness package:miniflare Relating to Miniflare and removed ci:no-changeset-required Skip pull request checks for a valid changeset labels Apr 24, 2026

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Apr 24, 2026

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13659

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13659

miniflare

npm i https://pkg.pr.new/miniflare@13659

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13659

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13659

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13659

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13659

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13659

wrangler

npm i https://pkg.pr.new/wrangler@13659

commit: 7880d61

Comment thread packages/miniflare/src/shared/dev-registry.ts

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

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Apr 24, 2026
@petebacondarwin petebacondarwin merged commit 3ceeec3 into main Apr 24, 2026
81 of 100 checks passed
@petebacondarwin petebacondarwin deleted the fix/dev-registry-windows-polling branch April 24, 2026 08:21
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-flake Applied to PRs addressing CI flakiness package:miniflare Relating to Miniflare

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants