Skip to content

Commit fa25a0c

Browse files
brandon-pereirateeohhemknudtty
authored
Improve search error isolation (#1175)
Co-authored-by: Tom Alexander <[email protected]> Co-authored-by: Aaron Knudtson <[email protected]>
1 parent 69a2a6a commit fa25a0c

File tree

4 files changed

+55
-39
lines changed

4 files changed

+55
-39
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
Improve search error isolation

packages/app/src/DBSearchPage.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,15 +1162,6 @@ function DBSearchPage() {
11621162
[onTimeRangeSelect],
11631163
);
11641164

1165-
const onTimeChartError = useCallback(
1166-
(error: Error | ClickHouseQueryError) =>
1167-
setQueryErrors(prev => ({
1168-
...prev,
1169-
DBTimeChart: error,
1170-
})),
1171-
[setQueryErrors],
1172-
);
1173-
11741165
const filtersChartConfig = useMemo<ChartConfigWithDateRange>(() => {
11751166
const overrides = {
11761167
orderBy: undefined,
@@ -1557,7 +1548,6 @@ function DBSearchPage() {
15571548
showDisplaySwitcher={false}
15581549
queryKeyPrefix={QUERY_KEY_PREFIX}
15591550
onTimeRangeSelect={handleTimeRangeSelect}
1560-
onError={onTimeChartError}
15611551
/>
15621552
</Box>
15631553
)}
@@ -1669,7 +1659,6 @@ function DBSearchPage() {
16691659
showDisplaySwitcher={false}
16701660
queryKeyPrefix={QUERY_KEY_PREFIX}
16711661
onTimeRangeSelect={handleTimeRangeSelect}
1672-
onError={onTimeChartError}
16731662
/>
16741663
</Box>
16751664
)}

packages/app/src/components/DBDeltaChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ export default function DBDeltaChart({
370370
const PAGE_SIZE = 12;
371371

372372
return (
373-
<Box>
373+
<Box style={{ overflow: 'auto' }}>
374374
<Flex justify="flex-end" mx="md" mb="md">
375375
<Pagination
376376
size="xs"

packages/app/src/components/DBTimeChart.tsx

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { memo, useMemo, useState } from 'react';
1+
import { memo, useEffect, useMemo, useState } from 'react';
22
import Link from 'next/link';
33
import cx from 'classnames';
44
import { add } from 'date-fns';
@@ -8,9 +8,10 @@ import {
88
ChartConfigWithDateRange,
99
DisplayType,
1010
} from '@hyperdx/common-utils/dist/types';
11-
import { Box, Button, Code, Collapse, Text } from '@mantine/core';
11+
import { Button, Code, Group, Modal, Text } from '@mantine/core';
1212
import { useDisclosure } from '@mantine/hooks';
1313
import { notifications } from '@mantine/notifications';
14+
import { IconArrowsDiagonal } from '@tabler/icons-react';
1415

1516
import { formatResponseForTimeChart, useTimeChartSettings } from '@/ChartUtils';
1617
import { convertGranularityToSeconds } from '@/ChartUtils';
@@ -26,7 +27,6 @@ function DBTimeChartComponent({
2627
config,
2728
enabled = true,
2829
logReferenceTimestamp,
29-
onError,
3030
onSettled,
3131
onTimeRangeSelect,
3232
queryKeyPrefix,
@@ -39,7 +39,6 @@ function DBTimeChartComponent({
3939
config: ChartConfigWithDateRange;
4040
enabled?: boolean;
4141
logReferenceTimestamp?: number;
42-
onError?: (error: Error | ClickHouseQueryError) => void;
4342
onSettled?: () => void;
4443
onTimeRangeSelect?: (start: Date, end: Date) => void;
4544
queryKeyPrefix?: string;
@@ -49,6 +48,7 @@ function DBTimeChartComponent({
4948
showLegend?: boolean;
5049
sourceId?: string;
5150
}) {
51+
const [isErrorExpanded, errorExpansion] = useDisclosure(false);
5252
const {
5353
displayType: displayTypeProp,
5454
dateRange,
@@ -67,9 +67,14 @@ function DBTimeChartComponent({
6767
placeholderData: (prev: any) => prev,
6868
queryKey: [queryKeyPrefix, queriedConfig],
6969
enabled,
70-
onError,
7170
});
7271

72+
useEffect(() => {
73+
if (!isError && isErrorExpanded) {
74+
errorExpansion.close();
75+
}
76+
}, [isError, isErrorExpanded, errorExpansion]);
77+
7378
const isLoadingOrPlaceholder = isLoading || isPlaceholderData;
7479
const { data: source } = useSource({ id: sourceId });
7580

@@ -178,31 +183,48 @@ function DBTimeChartComponent({
178183
Loading Chart Data...
179184
</div>
180185
) : isError ? (
181-
<div className="h-100 w-100 align-items-center justify-content-center text-muted overflow-auto">
186+
<div className="h-100 w-100 d-flex g-1 flex-column align-items-center justify-content-center text-muted overflow-auto">
182187
<Text ta="center" size="sm" mt="sm">
183188
Error loading chart, please check your query or try again later.
184189
</Text>
185-
<Box mt="sm">
186-
<Text my="sm" size="sm" ta="center">
187-
Error Message:
188-
</Text>
189-
<Code
190-
block
191-
style={{
192-
whiteSpace: 'pre-wrap',
193-
}}
194-
>
195-
{error.message}
196-
</Code>
197-
{error instanceof ClickHouseQueryError && (
198-
<>
199-
<Text my="sm" size="sm" ta="center">
200-
Sent Query:
201-
</Text>
202-
<SQLPreview data={error?.query} />
203-
</>
204-
)}
205-
</Box>
190+
<Button
191+
className="mx-auto"
192+
variant="subtle"
193+
color="red"
194+
onClick={() => errorExpansion.open()}
195+
>
196+
<Group gap="xxs">
197+
<IconArrowsDiagonal size={16} />
198+
See Error Details
199+
</Group>
200+
</Button>
201+
<Modal
202+
opened={isErrorExpanded}
203+
onClose={() => errorExpansion.close()}
204+
title="Error Details"
205+
>
206+
<Group align="start">
207+
<Text size="sm" ta="center">
208+
Error Message:
209+
</Text>
210+
<Code
211+
block
212+
style={{
213+
whiteSpace: 'pre-wrap',
214+
}}
215+
>
216+
{error.message}
217+
</Code>
218+
{error instanceof ClickHouseQueryError && (
219+
<>
220+
<Text my="sm" size="sm" ta="center">
221+
Sent Query:
222+
</Text>
223+
<SQLPreview data={error?.query} />
224+
</>
225+
)}
226+
</Group>
227+
</Modal>
206228
</div>
207229
) : graphResults.length === 0 ? (
208230
<div className="d-flex h-100 w-100 align-items-center justify-content-center text-muted">

0 commit comments

Comments
 (0)