Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilly-peaches-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---

Improve search error isolation
11 changes: 0 additions & 11 deletions packages/app/src/DBSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1162,15 +1162,6 @@ function DBSearchPage() {
[onTimeRangeSelect],
);

const onTimeChartError = useCallback(
(error: Error | ClickHouseQueryError) =>
setQueryErrors(prev => ({
...prev,
DBTimeChart: error,
})),
[setQueryErrors],
);

const filtersChartConfig = useMemo<ChartConfigWithDateRange>(() => {
const overrides = {
orderBy: undefined,
Expand Down Expand Up @@ -1557,7 +1548,6 @@ function DBSearchPage() {
showDisplaySwitcher={false}
queryKeyPrefix={QUERY_KEY_PREFIX}
onTimeRangeSelect={handleTimeRangeSelect}
onError={onTimeChartError}
/>
</Box>
)}
Expand Down Expand Up @@ -1669,7 +1659,6 @@ function DBSearchPage() {
showDisplaySwitcher={false}
queryKeyPrefix={QUERY_KEY_PREFIX}
onTimeRangeSelect={handleTimeRangeSelect}
onError={onTimeChartError}
/>
</Box>
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/components/DBDeltaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export default function DBDeltaChart({
const PAGE_SIZE = 12;

return (
<Box>
<Box style={{ overflow: 'auto' }}>
<Flex justify="flex-end" mx="md" mb="md">
<Pagination
size="xs"
Expand Down
75 changes: 48 additions & 27 deletions packages/app/src/components/DBTimeChart.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo, useMemo, useState } from 'react';
import { memo, useEffect, useMemo, useState } from 'react';
import Link from 'next/link';
import cx from 'classnames';
import { add } from 'date-fns';
Expand All @@ -8,9 +8,10 @@ import {
ChartConfigWithDateRange,
DisplayType,
} from '@hyperdx/common-utils/dist/types';
import { Box, Button, Code, Collapse, Text } from '@mantine/core';
import { Button, Code, Group, Modal, Text } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
import { notifications } from '@mantine/notifications';
import { IconArrowsDiagonal } from '@tabler/icons-react';

import { formatResponseForTimeChart, useTimeChartSettings } from '@/ChartUtils';
import { convertGranularityToSeconds } from '@/ChartUtils';
Expand All @@ -26,7 +27,6 @@ function DBTimeChartComponent({
config,
enabled = true,
logReferenceTimestamp,
onError,
onSettled,
onTimeRangeSelect,
queryKeyPrefix,
Expand All @@ -39,7 +39,6 @@ function DBTimeChartComponent({
config: ChartConfigWithDateRange;
enabled?: boolean;
logReferenceTimestamp?: number;
onError?: (error: Error | ClickHouseQueryError) => void;
onSettled?: () => void;
onTimeRangeSelect?: (start: Date, end: Date) => void;
queryKeyPrefix?: string;
Expand All @@ -49,6 +48,7 @@ function DBTimeChartComponent({
showLegend?: boolean;
sourceId?: string;
}) {
const [isErrorExpanded, errorExpansion] = useDisclosure(false);
const {
displayType: displayTypeProp,
dateRange,
Expand All @@ -67,9 +67,14 @@ function DBTimeChartComponent({
placeholderData: (prev: any) => prev,
queryKey: [queryKeyPrefix, queriedConfig],
enabled,
onError,
});

useEffect(() => {
if (!isError && isErrorExpanded) {
errorExpansion.close();
}
}, [isError, isErrorExpanded, errorExpansion]);

const isLoadingOrPlaceholder = isLoading || isPlaceholderData;
const { data: source } = useSource({ id: sourceId });

Expand Down Expand Up @@ -178,31 +183,47 @@ function DBTimeChartComponent({
Loading Chart Data...
</div>
) : isError ? (
<div className="h-100 w-100 align-items-center justify-content-center text-muted overflow-auto">
<div className="h-100 w-100 d-flex g-1 flex-column align-items-center justify-content-center text-muted overflow-auto">
<Text ta="center" size="sm" mt="sm">
Error loading chart, please check your query or try again later.
</Text>
<Box mt="sm">
<Text my="sm" size="sm" ta="center">
Error Message:
</Text>
<Code
block
style={{
whiteSpace: 'pre-wrap',
}}
>
{error.message}
</Code>
{error instanceof ClickHouseQueryError && (
<>
<Text my="sm" size="sm" ta="center">
Sent Query:
</Text>
<SQLPreview data={error?.query} />
</>
)}
</Box>
<Button
className="mx-auto"
variant="subtle"
onClick={() => errorExpansion.open()}
>
<Group gap="xxs">
<IconArrowsDiagonal size={16} />
See Error Details
</Group>
</Button>
<Modal
opened={isErrorExpanded}
onClose={() => errorExpansion.close()}
title="Error Details"
>
<Group align="start">
<Text size="sm" ta="center">
Error Message:
</Text>
<Code
block
style={{
whiteSpace: 'pre-wrap',
}}
>
{error.message}
</Code>
{error instanceof ClickHouseQueryError && (
<>
<Text my="sm" size="sm" ta="center">
Sent Query:
</Text>
<SQLPreview data={error?.query} />
</>
)}
</Group>
</Modal>
</div>
) : graphResults.length === 0 ? (
<div className="d-flex h-100 w-100 align-items-center justify-content-center text-muted">
Expand Down
Loading