Fix live graph never rendering (Infinity sample poisons maxValue)#167
Open
claudioabreu wants to merge 1 commit into
Open
Fix live graph never rendering (Infinity sample poisons maxValue)#167claudioabreu wants to merge 1 commit into
claudioabreu wants to merge 1 commit into
Conversation
At the very start of a measurement the elapsed time can be ~0, so the first speed sample (dTotal/dtTotal) evaluates to Infinity. isNaN(Infinity) is false, so the sample enters values[] and maxValue stays Infinity for the whole test: every point of the live graph collapses to y=height (invisible polygon) and calcPoints produces NaN coordinates (SVG errors in the console). Fix: only accept finite samples in Graph(), and guard the perc division in calcPoints. Applied to both app-2.5.4.js and app-2.5.4.min.js.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The live traffic graph inside the result cards never renders, and the console shows SVG errors like
Error: <polygon> attribute points: Expected number, "… NaN …".Root cause: at the very start of a measurement the elapsed time is ~0, so the first speed sample (
dTotal/dtTotal) evaluates toInfinity.isNaN(Infinity)isfalse, so the sample entersvalues[]andmaxValuestaysInfinityfor the entire test — every subsequent point ofcalcPoints()collapses toy = height(an invisible polygon along the baseline), andInfinity/Infinityproduces theNaNcoordinates seen in the console.Fix
Graph(): only accept finite samples (!isNaN(speed) && isFinite(speed));calcPoints(): guard thevalues[x]/maxValuedivision (isFinite(perc) || (perc = 0)).Applied to both
app-2.5.4.jsandapp-2.5.4.min.js(same logic, minified form).How to reproduce / validate
Run any speed test and watch the graphs in the result cards: before this patch they stay empty and the console logs the polygon/NaN error on every tick; after it, the download/upload graphs draw live and persist after the test.
Found while maintaining our fork (vialink/vialink-speedtest) — running in production with this fix since June 2026.