Commit 7cda98e
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 10ms initial delay after write on Windows
3. Verify file accessibility with up to 3 retries (10ms each)
4. Total potential wait time: 10ms + (3 × 10ms) = 40ms 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 kept minimal since the retry logic handles failures.
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"1 parent 1fb817e commit 7cda98e
1 file changed
+29
-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 | + | |
61 | 85 | | |
62 | 86 | | |
63 | 87 | | |
64 | | - | |
| 88 | + | |
65 | 89 | | |
66 | 90 | | |
67 | | - | |
| 91 | + | |
68 | 92 | | |
69 | | - | |
70 | | - | |
| 93 | + | |
| 94 | + | |
71 | 95 | | |
72 | 96 | | |
73 | 97 | | |
74 | 98 | | |
75 | 99 | | |
76 | 100 | | |
77 | | - | |
| 101 | + | |
78 | 102 | | |
79 | 103 | | |
80 | 104 | | |
| |||
0 commit comments