mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
fix bug where reading value when server is offline could throw client error (#1154)
This commit is contained in:
parent
c48f418114
commit
5c88c46375
2 changed files with 30 additions and 16 deletions
5
.changeset/short-peas-sin.md
Normal file
5
.changeset/short-peas-sin.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@hyperdx/app": patch
|
||||
---
|
||||
|
||||
fix bug where reading value when server is offline could throw client error
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue