Commit be531d9
authored
fix: move safety timeout to connect event (#111)
The ndt7-js client sets a 12s safety timeout when the worker is created
(`runNDT7Worker`, line 206). This timeout covers the entire worker
lifecycle including WebSocket connection setup (TCP + TLS + WS upgrade ≈
3 RTTs). For a 10s test with a 2s margin, clients with RTT > ~667ms have
their tests terminated early by the client before the server's 10s
duration expires.
This is the same bug fixed in msak-js (m-lab/msak-js#23).
BQ data confirms the effect (ndt7 downloads, one week sample Feb 2025):
| RTT bucket | Median elapsed (of 10s) | Median shortfall | % tests < 9s
|
|---|---|---|---|
| <20ms | 9.79s | 0.21s | 38% |
| 200-500ms | 9.20s | 0.80s | 47% |
| 500ms+ | **5.84s** | **4.17s** | **78%** |
The fix splits the single 12s timeout into two:
- **Connection timeout (10s)**: set at worker creation, protects against
WebSocket connections that never open. Cleared when the worker reports
`start` (i.e. `sock.onopen`).
- **Test duration timeout (12s)**: set when the `start` message arrives,
so handshake time does not eat into the test duration.
<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/m-lab/ndt7-js/111)
<!-- Reviewable:end -->1 parent 6c98f16 commit be531d9
1 file changed
+17
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
210 | 213 | | |
211 | 214 | | |
212 | 215 | | |
| 216 | + | |
213 | 217 | | |
214 | 218 | | |
215 | 219 | | |
216 | 220 | | |
217 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
218 | 227 | | |
219 | 228 | | |
220 | 229 | | |
| |||
241 | 250 | | |
242 | 251 | | |
243 | 252 | | |
244 | | - | |
| 253 | + | |
| 254 | + | |
245 | 255 | | |
246 | 256 | | |
247 | 257 | | |
| |||
0 commit comments