Skip to content

Fix live graph never rendering (Infinity sample poisons maxValue) - #167

Open
claudioabreu wants to merge 1 commit into
openspeedtest:mainfrom
claudioabreu:fix-live-graph-infinity
Open

Fix live graph never rendering (Infinity sample poisons maxValue)#167
claudioabreu wants to merge 1 commit into
openspeedtest:mainfrom
claudioabreu:fix-live-graph-infinity

Conversation

@claudioabreu

Copy link
Copy Markdown

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 to Infinity. isNaN(Infinity) is false, so the sample enters values[] and maxValue stays Infinity for the entire test — every subsequent point of calcPoints() collapses to y = height (an invisible polygon along the baseline), and Infinity/Infinity produces the NaN coordinates seen in the console.

Fix

  • Graph(): only accept finite samples (!isNaN(speed) && isFinite(speed));
  • calcPoints(): guard the values[x]/maxValue division (isFinite(perc) || (perc = 0)).

Applied to both app-2.5.4.js and app-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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant