Fix multiple idle latency steps overriding previous measurements#132
Conversation
There was a problem hiding this comment.
Review summary
What this PR does
- Fixes a real bug where multiple
{ type: 'latency' }steps in the measurements config clobber each other. Because#curTypeResults()keysrawby measurement type (src/index.ts:263-269), everylatencystep reads/writes the sameraw.latencyobject. Each phase's callback didmsmResults.results = Object.assign({}, res.down[0]), replacing the whole object and dropping the prior phase's timings. The fix snapshotspriorTimingswhen the phase starts and prepends them on each callback, so all phases accumulate into onetimingsarray. Diagnosis and approach are correct. - Adds a
console.log('results', logData)inlogFinalResults.tsbefore the__resultsPOST.
Correctness verification
- No double-counting: the engine rebuilds
res.down[0].timingscumulatively within a phase (BandwidthEngine.ts:296-299), andpriorTimingsis a fixed snapshot of previous phases, prepended fresh each callback. Correct. - Pause/resume is safe:
latencyis pausable, but resume returns early in#next()without re-entering the switch (src/index.ts:304-315), sopriorTimingsis captured exactly once per phase. Correct.
Overall the core fix is sound. A couple of minor issues flagged inline.
|
Review posted to PR #132. SummaryWhat the PR changes
Verdict on the fix: The core fix is correct. I verified no double-counting (the engine rebuilds its timings cumulatively within a phase, and Issues flagged inline
No correctness or security blockers. No commits pushed. |
fa93715 to
1f87d43
Compare
When multiple
{ type: 'latency' }steps exist in the measurements config (e.g. the interleaved 2-ping idle probes added between bandwidth phases), each step was overwriting the previous step's timings inraw.latency.results. Only the last latency phase's data survived.This fix snapshots the existing timings before each latency phase starts and prepends them on each measurement callback, so all phases accumulate into a single timings array.
Also logs the results payload to the console before submission to
__results.