Commit ec553d9
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 50ms initial delay after write on Windows
3. Verify file accessibility with up to 5 retries with increasing delays (20ms, 40ms, 60ms, 80ms, 100ms)
4. Add 10ms stabilization delay after successful access
5. Total potential wait time: 50ms + (20+40+60+80+100)ms + 10ms = 360ms 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 significantly
slower than local development environments.
This fixes all intermittent test failures in Windows CI runners.1 parent 1fb817e commit ec553d9
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