Repository navigation
Commit 5211a84
test: scale broker/app-server spawn timeouts under CPU contention (#53)
Concurrent `npm test` runs made unrelated tests fail at almost exactly
5000ms: the broker-smoke IPC-ready wait and the withAppServer fallback
watchdogs budget real process spawns, so under contention they lost the
race against the machine rather than catching a logic defect.
Add scaleTimeout() in tests/helpers.mjs and apply it to those budgets.
The multiplier is a flat base rather than an os.loadavg() derivation:
loadavg is a 1-minute average that still reads near-idle during the
first seconds of a burst, which is exactly when these deadlines are
computed — a load-derived multiplier measured 1x while the work needed
4x, and the suite still failed at a flat 5000ms. loadavg is kept only
as a floor for the case where it has caught up. Handshake deadlines
that are themselves under test (300/500ms) stay unscaled.
Also clear the losing watchdog timer via a raceHang() helper. A bare
setTimeout in a Promise.race keeps the event loop alive for the full
budget even when the real promise wins; scaling the budget exposed this,
inflating the file from 6.7s to 31.5s wall-clock. Clearing it brings the
two files to 2.98s, faster than before this change.
Verified on a 10-core box: 10 concurrent runs of the two files went
10/10 red before, 10/10 green after. Beyond ~10 (1x cores) the failures
change character — they hit the production SPAWNED_INITIALIZE_TIMEOUT_MS
(10s) in app-server.mjs, which is a genuine signal and deliberately left
alone. Full suite 194/194 green; tsc build clean.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0185ypzB1bqu9CLxTVyWdrzx1 parent e470027 commit 5211a84
3 files changed
Lines changed: 96 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
10 | 32 | | |
11 | 33 | | |
12 | 34 | | |
| |||
17 | 39 | | |
18 | 40 | | |
19 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
20 | 46 | | |
21 | 47 | | |
22 | 48 | | |
| |||
25 | 51 | | |
26 | 52 | | |
27 | 53 | | |
28 | | - | |
| 54 | + | |
29 | 55 | | |
30 | 56 | | |
31 | 57 | | |
32 | 58 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
36 | 62 | | |
37 | 63 | | |
38 | 64 | | |
| |||
58 | 84 | | |
59 | 85 | | |
60 | 86 | | |
61 | | - | |
| 87 | + | |
62 | 88 | | |
63 | 89 | | |
64 | 90 | | |
| |||
72 | 98 | | |
73 | 99 | | |
74 | 100 | | |
75 | | - | |
76 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
77 | 104 | | |
78 | 105 | | |
79 | 106 | | |
| |||
97 | 124 | | |
98 | 125 | | |
99 | 126 | | |
100 | | - | |
| 127 | + | |
101 | 128 | | |
102 | 129 | | |
103 | 130 | | |
| |||
113 | 140 | | |
114 | 141 | | |
115 | 142 | | |
116 | | - | |
117 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
118 | 146 | | |
119 | 147 | | |
120 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
| 35 | + | |
33 | 36 | | |
34 | | - | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
30 | 82 | | |
31 | 83 | | |
32 | 84 | | |
| |||
0 commit comments