Commit 4c88324
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 multiple strategies:
1. **Retry on ENOENT errors** (not just EPERM/EBUSY) - this is the critical fix
2. Increase initial delay to 50ms (from 20ms) for more reliable file flushing
3. Increase max access retries to 5 (from 3) for slower CI environments
4. Add exponential backoff for access retries: 30ms, 60ms, 90ms, 120ms, 150ms
5. Add 10ms stabilization delay after successful access
6. Total potential wait time: up to 50ms + (30+60+90+120+150)ms + 10ms = 510ms
Root cause: The write itself can fail with ENOENT on Windows if the filesystem
is slow to make the file available. The previous code only retried EPERM/EBUSY
errors, so ENOENT would immediately fail. Adding ENOENT to the retry conditions
is the key fix that resolves all the intermittent 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 4c88324
1 file changed
+34
-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 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
61 | 90 | | |
62 | 91 | | |
63 | 92 | | |
64 | | - | |
| 93 | + | |
65 | 94 | | |
66 | 95 | | |
67 | | - | |
| 96 | + | |
68 | 97 | | |
69 | | - | |
70 | | - | |
| 98 | + | |
| 99 | + | |
71 | 100 | | |
72 | 101 | | |
73 | 102 | | |
74 | 103 | | |
75 | 104 | | |
76 | 105 | | |
77 | | - | |
| 106 | + | |
78 | 107 | | |
79 | 108 | | |
80 | 109 | | |
| |||
0 commit comments