Do not access graph DOM elements if view was already destroyed
This commit is contained in:
@@ -65,6 +65,9 @@ async function liveRefresh() {
|
||||
metricStream.onmessage = (message) => {
|
||||
const data = JSON.parse(message.data);
|
||||
|
||||
// stop here if the DOM elements are already gone due to view change
|
||||
if (!cpuGraphItem.value) return;
|
||||
|
||||
cpuGraphItem.value.pushData(0, data[app.id].cpu);
|
||||
memoryGraphItem.value.pushData(0, data[app.id].memory);
|
||||
diskGraphItem.value.pushData(0, data[app.id].blockReadRate, data[app.id].blockWriteRate);
|
||||
@@ -102,6 +105,9 @@ async function rebuild() {
|
||||
blockWriteTotal.value = prettyDecimalSize(metrics.blockWriteTotal);
|
||||
}
|
||||
|
||||
// stop here if the DOM elements are already gone due to view change
|
||||
if (!cpuGraphItem.value) return;
|
||||
|
||||
cpuGraphItem.value.setDatasets(datasets.cpu);
|
||||
memoryGraphItem.value.setDatasets(datasets.memory);
|
||||
diskGraphItem.value.setDatasets(datasets.disk);
|
||||
|
||||
Reference in New Issue
Block a user