fix bug where reading value when server is offline could throw client error (#1154)

This commit is contained in:
Brandon Pereira 2025-09-10 15:07:57 -06:00 committed by GitHub
parent c48f418114
commit 5c88c46375
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 16 deletions

View file

@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---
fix bug where reading value when server is offline could throw client error

View file

@ -75,22 +75,31 @@ function DBTimeChartComponent({
const { graphResults, timestampColumn, groupKeys, lineNames, lineColors } =
useMemo(() => {
return data != null && isSuccess
? formatResponseForTimeChart({
res: data,
dateRange,
granularity,
generateEmptyBuckets: fillNulls !== false,
source,
})
: {
graphResults: [],
timestampColumn: undefined,
groupKeys: [],
lineNames: [],
lineColors: [],
};
}, [data, dateRange, granularity, isSuccess, fillNulls]);
const defaultResponse = {
graphResults: [],
timestampColumn: undefined,
groupKeys: [],
lineNames: [],
lineColors: [],
};
if (data == null || !isSuccess) {
return defaultResponse;
}
try {
return formatResponseForTimeChart({
res: data,
dateRange,
granularity,
generateEmptyBuckets: fillNulls !== false,
source,
});
} catch (e) {
console.error(e);
return defaultResponse;
}
}, [data, dateRange, granularity, isSuccess, fillNulls, source]);
// To enable backward compatibility, allow non-controlled usage of displayType
const [displayTypeLocal, setDisplayTypeLocal] = useState(displayTypeProp);