-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Description
On macOS, the config file watcher triggers continuous reloads (~every 5 seconds) even when the .miyagi.js file has not been modified. This is caused by macOS system processes (Spotlight indexing, Time Machine, etc.) triggering fs.watch events.
Environment
- OS: macOS
- Miyagi: 4.0.1
- Node.js: 20+
Steps to Reproduce
- Create a Miyagi project on macOS
- Run
miyagi start - Wait 15-20 seconds without making any changes
- Observe terminal output
Observed Behavior
2026/01/04 13:56:17 Info: Updating configuration…
2026/01/04 13:56:18 Success: Reloading browser window!
2026/01/04 13:56:18 Success: Updating done!
2026/01/04 13:56:22 Info: Updating configuration…
2026/01/04 13:56:22 Success: Reloading browser window!
2026/01/04 13:56:22 Success: Updating done!
This repeats indefinitely at ~5 second intervals.
Expected Behavior
No config reloads should occur unless the user actually modifies .miyagi.js.
Root Cause Analysis
The config file watcher in lib/init/watcher.js (lines 335-341) uses Node's fs.watch:
if (global.config.userFileName) {
fs.watch(global.config.userFileName, async (eventType) => {
if (eventType === "change") {
configurationFileUpdated();
}
});
}Issues identified:
- No debouncing: Unlike the regular file watcher (which uses a
timeout), the config watcher processes every event immediately - macOS FSEvents quirks:
fs.watchon macOS receives spurious "change" events from system processes (Spotlight, Time Machine, mds, etc.) that access/index files - No way to disable: There is no config option to turn off config file watching
Proposed Solution
Add a ui.watchConfigFile option (default: false to avoid this issue):
1. In lib/default-config.js:
ui: {
// ... existing options
watchConfigFile: false, // Disable by default due to macOS issues
}2. In lib/init/watcher.js:
if (global.config.userFileName && global.config.ui.watchConfigFile) {
fs.watch(global.config.userFileName, async (eventType) => {
if (eventType === "change") {
configurationFileUpdated();
}
});
}Workaround
Users can patch locally using patch-package with the changes above.
Additional Context
- This issue does NOT affect Linux (inotify is more reliable than FSEvents)
- The spurious events occur regardless of whether the user is actively using the system
- Tested with fresh projects—the issue persists
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels