Commit c4e75ff
authored
* fix: add Promise.race hard timeout to feature flags fetch (#465)
On Windows + Node 24 / undici 7.x, AbortController.abort() fails to
interrupt an in-progress TCP connect — the fetch hangs until the OS-level
TCP timeout (~30s). This blocks the MCP initialize response for users
on high-latency networks (e.g. Australia).
Changes:
- fetchFlags(): wrap fetch in Promise.race with hard 3s timeout alongside
AbortController, so the JS-level timeout is enforced regardless of
whether AbortController actually interrupts the underlying socket
- waitForFreshFlags(): add 5s safety timeout so it can never hang
indefinitely (protects the new-user onboarding path that awaits this
inside the MCP initialize handler)
- Lower fetch timeout from 5s to 3s — flags load from cache anyway,
a fresh fetch is not worth perceived startup latency
- Add test/test-feature-flags-timeout.js with 6 tests covering:
AbortController behavior, Promise.race pattern, slow-response servers,
new-user onboarding path, and simulated broken AbortController
1 parent c74339f commit c4e75ff
2 files changed
Lines changed: 472 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
116 | 119 | | |
117 | 120 | | |
118 | 121 | | |
119 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
120 | 133 | | |
121 | 134 | | |
122 | 135 | | |
| |||
150 | 163 | | |
151 | 164 | | |
152 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
153 | 171 | | |
154 | 172 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
160 | 181 | | |
161 | 182 | | |
162 | 183 | | |
163 | 184 | | |
164 | 185 | | |
165 | | - | |
166 | | - | |
167 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
168 | 195 | | |
169 | 196 | | |
170 | 197 | | |
| |||
183 | 210 | | |
184 | 211 | | |
185 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
186 | 218 | | |
187 | 219 | | |
188 | 220 | | |
| |||
0 commit comments