Skip to content

Fix uncaught ApexCharts error on dashboard load (#249)#250

Open
misterbh-saashup wants to merge 2 commits into
mainfrom
fix/apexcharts-chart-load-error
Open

Fix uncaught ApexCharts error on dashboard load (#249)#250
misterbh-saashup wants to merge 2 commits into
mainfrom
fix/apexcharts-chart-load-error

Conversation

@misterbh-saashup
Copy link
Copy Markdown
Collaborator

Fix uncaught ApexCharts error on dashboard load

Fixes #249.

Problem

On every dashboard load, ApexCharts threw an uncaught exception while drawing the system-usage donut:

TypeError: Cannot read properties of undefined (reading 'type')
    at … apexcharts.min.js … create()

Root cause

The chart's series was built directly from /system/usage:

const series = [ result.layers_size, result.images.size,  ]

But /system/usage omits some keys depending on daemon state — on an empty daemon it returns:

{"images":{"shared_size":0,"size":0},"containers":{"size_rootfs":0},"volumes":0,"build_cache":0}

— no layers_size. So series[0] was undefined, and ApexCharts can't render an undefined data point, which is where the error originates (inside the library's create()). The chart still rendered, so it was easy to miss, but it was a real uncaught error on load.

Fix

Coerce every series value to a finite number (missing → 0) so the series is always valid:

const num = (x) => (typeof x === 'number' && isFinite(x) ? x : 0)
const series = [ num(result.layers_size), num(result.images && result.images.size),  ]

Verification

An automated 25-load check (Playwright, listening for pageerror) went from 25/25 loads erroring → 0/25, and the chart still renders (SVG present, host info populated).

Follow-up

This is the error the Playwright navigation smoke test in #248 currently tolerates. Once both this and #248 are merged, that tolerance (and the KNOWN ISSUE (#249) filter in tests/e2e/tests/01-navigation.spec.ts) can be removed.

houinbe added 2 commits June 2, 2026 20:47
The system-usage donut built its series straight from /system/usage, but that
endpoint omits some keys depending on daemon state — e.g. `layers_size` is
absent on an empty daemon — so the first series value was `undefined`.
ApexCharts cannot render an undefined data point and threw
"Cannot read properties of undefined (reading 'type')" from inside create(),
an uncaught error on every page load (the chart happened to still render).

Coerce every series value to a finite number (missing -> 0) so the series is
always valid.

Verified: an automated 25-load check went from 25/25 erroring to 0/25, and the
chart still renders.

Fixes #249
Remove the tolerance for the ApexCharts load error from the navigation smoke
test. With the chart series fix in this PR the dashboard loads with no uncaught
errors, so the test asserts an empty error list again.
@misterbh-saashup misterbh-saashup force-pushed the fix/apexcharts-chart-load-error branch from d9b9296 to 02d1820 Compare June 2, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web UI: ApexCharts throws an uncaught TypeError on load (system-usage chart)

1 participant