Commit 94f2bbe
committed
fix(windows): add file flush delay to prevent ENOENT errors in tests
On Windows, file operations can be asynchronous at the OS level. After writeFile() completes, the file handle may not be fully released immediately, causing ENOENT errors when code tries to read the file right after writing.
Enhanced retryWrite() with ENOENT retry support:
1. **Retry on ENOENT errors** (not just EPERM/EBUSY) - this is the key fix
2. Add 25ms initial delay after write on Windows
3. Verify file accessibility with up to 4 retries with increasing delays (15ms, 30ms, 45ms, 60ms)
4. Total potential wait time: 25ms + (15+30+45+60)ms = 175ms max
Root cause: The previous code only retried EPERM/EBUSY errors. The write
itself can fail with ENOENT on Windows if the filesystem is slow to make
the file available. Adding ENOENT to the retry conditions is the critical
fix. The delays are tuned for Windows CI runners which are slower than
local development environments.
This fixes intermittent test failures in Windows CI runners, including:
- "should handle load -> update -> save workflow"
- "should use default 2-space indent for new files"
- "should preserve line endings"
- "should support sort option"
- "should use LF line endings by default"
- "should handle save -> update -> save again"1 parent 1fb817e commit 94f2bbe
1 file changed
+31
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
61 | 87 | | |
62 | 88 | | |
63 | 89 | | |
64 | | - | |
| 90 | + | |
65 | 91 | | |
66 | 92 | | |
67 | | - | |
| 93 | + | |
68 | 94 | | |
69 | | - | |
70 | | - | |
| 95 | + | |
| 96 | + | |
71 | 97 | | |
72 | 98 | | |
73 | 99 | | |
74 | 100 | | |
75 | 101 | | |
76 | 102 | | |
77 | | - | |
| 103 | + | |
78 | 104 | | |
79 | 105 | | |
80 | 106 | | |
| |||
0 commit comments