Commit 254a69d
fix(node18): make telemetry fail-safe + openAsBlob fallback + scope fake timers
CI's Node 18.20 job (supported per engines: node >=18.20.0; wdio v9 supports 18.20) surfaced three Node-18-only failures that Node 20/22 tolerate:
1. PerformanceTester.start/end/measure called performance.mark/measure directly. Under vitest's full fake timers (7 test files) performance.now() goes negative, and Node 18's perf_hooks rejects negative timestamps (ERR_PERFORMANCE_INVALID_TIMESTAMP), throwing out of callers' before() hooks. Routed all mark/measure through safeMark/safeMeasure wrappers — instrumentation must never throw into business logic (no-op on the happy path; transparent on Node 20+).
2. uploadLogs used fs.openAsBlob (Node >=20 only). Added a Node-18 fallback to new Blob([readFileSync]) for the small log archive.
3. util.test.ts faked via bare useFakeTimers(); scoped to toFake:['Date'] (it never advances timers), matching reporter.test.ts.
Verified locally on Node 18.20.5 AND Node 22: npm ci + build + 980/980 tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 67b9cef commit 254a69d
3 files changed
Lines changed: 36 additions & 16 deletions
File tree
- packages/browserstack-service
- src
- instrumentation/performance
- tests
Lines changed: 24 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
21 | 33 | | |
22 | 34 | | |
23 | 35 | | |
| |||
224 | 236 | | |
225 | 237 | | |
226 | 238 | | |
227 | | - | |
| 239 | + | |
228 | 240 | | |
229 | 241 | | |
230 | 242 | | |
| |||
240 | 252 | | |
241 | 253 | | |
242 | 254 | | |
243 | | - | |
244 | | - | |
| 255 | + | |
| 256 | + | |
245 | 257 | | |
246 | 258 | | |
247 | 259 | | |
| |||
255 | 267 | | |
256 | 268 | | |
257 | 269 | | |
258 | | - | |
259 | | - | |
| 270 | + | |
| 271 | + | |
260 | 272 | | |
261 | 273 | | |
262 | 274 | | |
| |||
274 | 286 | | |
275 | 287 | | |
276 | 288 | | |
277 | | - | |
278 | | - | |
| 289 | + | |
| 290 | + | |
279 | 291 | | |
280 | 292 | | |
281 | 293 | | |
| |||
289 | 301 | | |
290 | 302 | | |
291 | 303 | | |
292 | | - | |
293 | | - | |
| 304 | + | |
| 305 | + | |
294 | 306 | | |
295 | 307 | | |
296 | 308 | | |
| |||
309 | 321 | | |
310 | 322 | | |
311 | 323 | | |
312 | | - | |
| 324 | + | |
313 | 325 | | |
314 | 326 | | |
315 | 327 | | |
316 | 328 | | |
317 | | - | |
318 | | - | |
| 329 | + | |
| 330 | + | |
319 | 331 | | |
320 | 332 | | |
321 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1454 | 1454 | | |
1455 | 1455 | | |
1456 | 1456 | | |
1457 | | - | |
1458 | | - | |
| 1457 | + | |
| 1458 | + | |
1459 | 1459 | | |
1460 | | - | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
1461 | 1465 | | |
1462 | 1466 | | |
1463 | 1467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
0 commit comments