Gracefully fall back when `fs.watch()` is unsupported on SMB/network filesystems
What variant of Codex are you using?
VSCode Extension
What feature would you like to see?
Summary
Please improve support for repositories hosted on Windows SMB/network filesystems where fs.watch() is unavailable or unreliable.
In our environment, repositories are stored on an SMB share exported by Samba. Git operations work normally, but Node.js fs.watch() fails, causing the VS Code Extension to repeatedly log Git watcher warnings instead of gracefully degrading.
Environment
- Codex VS Code Extension
- Windows 11
- Node.js v24.18.0
- Git for Windows
- Repository located on an SMB share (Samba)
Observed behavior
Codex repeatedly logs warnings similar to:
[git-repo-watcher] Git repo watcher failed
UNKNOWN: unknown error, watch
The same failure can be reproduced outside of Codex using Node.js alone.
Repository root:
const fs = require("fs");
fs.watch(".", () => {})
.on("error", console.error);
console.log("watch ok");
setTimeout(() => {}, 10000);
Output:
watch ok
Error: UNKNOWN: unknown error, watch
at FSWatcher._handle.onchange (node:internal/fs/watchers:267:21)
The identical script succeeds on a local NTFS directory and fails only when run from the SMB workspace.
I also confirmed this is unrelated to Git metadata. Initially, Git for Windows reported file mode changes (core.filemode=true), but after setting:
git config core.filemode false
the working tree became clean while the fs.watch() failures remained unchanged.
Requested enhancement
When filesystem notifications cannot be established for a workspace, Codex should gracefully support that environment instead of repeatedly attempting unsupported watchers.
One possible implementation would be to detect the failure once and fall back to a polling-based repository refresh strategy, but any approach that allows Codex to function without continuous watcher failures would solve the problem.
Additional information
I believe this is an enhancement rather than a bug.
The underlying limitation appears to be Node.js fs.watch() on Windows network filesystems rather than Git or Codex itself. The request is for Codex to detect that condition and gracefully degrade instead of repeatedly attempting unsupported filesystem watchers.
To help isolate the issue, I also verified the following:
- Git operations function normally on the SMB share after configuring
core.filemode=false. - The
fs.watch()failure reproduces with a minimal standalone Node.js program, independent of Codex. - The same Node.js program succeeds on a local NTFS directory.
- The failure occurs on both the repository root and newly-created directories on the SMB share, indicating it is not specific to Git metadata.
I would be happy to provide additional diagnostics or test candidate fixes against this environment if it would be helpful.
1 Comment
Thanks for the detailed reproduction. This looks like a filesystem capability gap rather than a Git-only issue, so a single failure probe at watcher init may be the safest fix: attempt
fs.watch()once, and on the firstUNKNOWN: unknown error, watch/ENOTSUPresponse, disable active watcher mode for that workspace and switch to bounded polling for repo status refresh.Suggested fallback behavior:
If you want, I can also test a minimal repro harness against
git-repo-watcherto validate the fallback trigger path once it’s implemented.