Skip to content
Merged
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/many-tomatoes-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---

fix: Prevent crashes on Services and ClickHouse dashboards
7 changes: 4 additions & 3 deletions packages/app/src/ClickhousePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { format as formatSql } from '@hyperdx/common-utils/dist/sqlFormatter';
import { DisplayType } from '@hyperdx/common-utils/dist/types';
import {
Box,
BoxComponentProps,
Button,
Flex,
Grid,
Expand All @@ -38,6 +37,7 @@ import OnboardingModal from './components/OnboardingModal';
import { useDashboardRefresh } from './hooks/useDashboardRefresh';
import { useConnections } from './connection';
import { parseTimeQuery, useNewTimeQuery } from './timeQuery';
import { usePrevious } from './utils';

// TODO: This is a hack to set the default time range
const defaultTimeRange = parseTimeQuery('Past 1h', false) as [Date, Date];
Expand Down Expand Up @@ -443,12 +443,13 @@ function ClickhousePage() {
});

const watchedConnection = useWatch({ control, name: 'connection' });
const previousWatchedConnection = usePrevious(watchedConnection);

useEffect(() => {
if (watchedConnection !== connection) {
if (previousWatchedConnection !== watchedConnection) {
setConnection(watchedConnection ?? null);
}
}, [watchedConnection, connection, setConnection]);
}, [watchedConnection, setConnection, previousWatchedConnection]);
const DEFAULT_INTERVAL = 'Past 1h';
const [displayedTimeInputValue, setDisplayedTimeInputValue] =
useState(DEFAULT_INTERVAL);
Expand Down
17 changes: 13 additions & 4 deletions packages/app/src/ServicesDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import { IS_LOCAL_MODE } from './config';
import DashboardFilters from './DashboardFilters';
import DashboardFiltersModal from './DashboardFiltersModal';
import { HARD_LINES_LIMIT } from './HDXMultiSeriesTimeChart';
import { usePrevious } from './utils';

type AppliedConfigParams = {
source?: string | null;
Expand Down Expand Up @@ -1431,7 +1432,11 @@ function ServicesDashboardPage() {
});

const service = useWatch({ control, name: 'service' });
const previousService = usePrevious(service);

const sourceId = useWatch({ control, name: 'source' });
const previousSourceId = usePrevious(sourceId);

const { data: source } = useSource({
id: sourceId,
});
Expand Down Expand Up @@ -1500,18 +1505,22 @@ function ServicesDashboardPage() {
}, [handleSubmit, setAppliedConfigParams, onSearch, displayedTimeInputValue]);

// Auto-submit when source changes
// Note: do not include appliedConfig.source in the deps,
// to avoid infinite render loops when navigating away from the page
useEffect(() => {
if (sourceId && sourceId !== appliedConfig.source) {
if (sourceId && sourceId != previousSourceId) {
onSubmit();
}
}, [sourceId, appliedConfig.source, onSubmit]);
}, [sourceId, onSubmit, previousSourceId]);

// Auto-submit when service changes
// Note: do not include appliedConfig.service in the deps,
// to avoid infinite render loops when navigating away from the page
useEffect(() => {
if (service !== appliedConfig.service) {
if (service != previousService) {
onSubmit();
}
}, [service, appliedConfig.service, onSubmit]);
}, [service, onSubmit, previousService]);

return (
<Box p="sm">
Expand Down
Loading