Skip to content

fix(runtime): poll config file as safety net for dropped fsnotify events - #1637

Merged
Dumbris merged 3 commits into
mainfrom
fix/config-watcher-revert-flake
Oct 17, 2026
Merged

Dumbris merged 3 commits into
mainfrom
fix/config-watcher-revert-flake

Conversation

@Dumbris

@Dumbris Dumbris commented Oct 16, 2026

Copy link
Copy Markdown
Member

Root cause

TestConfigWatcher_ExternalRevertToLastSelfWriteReloads flaked on macOS-15 runners (#1629, #1634). It is not a self-write-marker bug: with debug instrumentation under CPU load (reproduced ~1 in 100-250 runs locally on macOS), the final external revert to byte-identical A produced no fsnotify event at all after B's reload, so no debounce fired and the config stayed on B. fsnotify's kqueue backend can drop the event for a rename-over that follows a recently handled one. This is a real production hole (an external edit can be silently missed until restart), not only a test timing issue.

Fix

runConfigWatchLoop now also polls (2s) and compares file bytes with the last evaluated content; on a difference it arms the normal debounce -> reloadFromDiskIfChanged path, so self-write suppression is unchanged. The poll does not re-arm a pending debounce.

Tests

  • New TestConfigWatcher_PollRecoversMissedFsEvent deterministically simulates total event loss (watch on an unrelated dir) and fails without the poll.
  • Before: 2 failures in ~120 runs, 1 in 250 (12 CPU spinners + 10 parallel test processes). After: 0 failures in 100 runs of the whole TestConfigWatcher_ suite under the same load, plus 20 clean sequential -race runs.
  • golangci-lint (bare and --build-tags server) on internal/runtime: only a pre-existing reflect.Ptr inline finding in event_bus.go, untouched here.

…vents

fsnotify's kqueue backend (macOS) can drop the event for a config
rename-over that lands right after a previous one. Instrumented stress
runs showed the external revert to byte-identical self-written bytes
produced no watcher event at all, so the running config stayed stale
(TestConfigWatcher_ExternalRevertToLastSelfWriteReloads flaked on
macOS-15 CI in #1629 and #1634).

The watch loop now also compares the file bytes with the last evaluated
content every 2s and, when they differ, runs the normal debounce ->
reloadFromDiskIfChanged path (self-write suppression unchanged).
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/config-watcher-revert-flake

Available Artifacts

  • archive-darwin-amd64 (31 MB)
  • archive-darwin-arm64 (28 MB)
  • archive-linux-amd64 (19 MB)
  • archive-linux-arm64 (17 MB)
  • archive-windows-amd64 (31 MB)
  • archive-windows-arm64 (28 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (27 MB)
  • installer-dmg-darwin-arm64 (25 MB)
  • smart-mcp-proxymcpproxy-goQ4MMAH.dockerbuild (0 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 38917489320 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Dumbris
Dumbris merged commit 7316144 into main Oct 17, 2026
47 checks passed
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