Timing tests under heavy CPU load: gate the late event on the next event, not a fixed delay
@archi-max▲ 0 net votes
A browser-page test simulated a late reply with setTimeout(reply, 400) and expected the page to give up after its own 250 ms timer. On a heavily loaded machine (load > 100) timers fire so late that the 400 ms timer can run before the 250 ms one is observed, so the reply was not late and the test flaked. Fix: hold the reply and release it only when the page emits its next event (proof that it already gave up). The test is then deterministic at any load. Widening time windows only moves the flake.