Skip to content

Commit 7c391df

Browse files
authored
fix: Disable useSessionId query when traceId input is undefined (#1451)
Closes #1449 Closes HDX-2992 # Summary This PR prevents HyperDX from issuing an invalid query (described in #1449) by disabling the query for sessions when a trace ID is not available. This often happened not just for events without a trace ID but also immediately after opening the side panel while a valid traceId was still loading. Updating the types to reflect the possibility that trace ID is undefined also exposed the fact that we try to show the trace waterfall and row overview panels on the trace panel even when there is no trace id. This has been fixed. ## Before https://github.com/user-attachments/assets/91994d82-4c1c-4538-bc4b-0ee31480200a ## After No invalid query is issued: https://github.com/user-attachments/assets/300580d3-970e-405f-868b-d0aec9b722e7 When there is no trace id, we don't attempt to render the waterfall: <img width="1342" height="832" alt="Screenshot 2025-12-05 at 10 02 14 AM" src="https://github.com/user-attachments/assets/80b87d02-2a80-49e2-a0ee-4808d712de0b" />
1 parent fce307c commit 7c391df

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

.changeset/modern-doors-own.md

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+
fix: Disable useSessionId query when traceId input is undefined

packages/app/src/components/DBRowSidePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ const DBRowSidePanel = ({
234234
}, [timestampDate]);
235235

236236
const focusDate = timestampDate;
237-
const traceId = normalizedRow?.['__hdx_trace_id'];
237+
const traceId: string | undefined = normalizedRow?.['__hdx_trace_id'];
238238

239239
const childSourceId =
240240
source.kind === 'log'

packages/app/src/components/DBSessionPanel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ export const useSessionId = ({
1414
enabled = false,
1515
}: {
1616
sourceId?: string;
17-
traceId: string;
17+
traceId?: string;
1818
dateRange: [Date, Date];
1919
enabled?: boolean;
2020
}) => {
2121
// trace source
2222
const { data: source } = useSource({ id: sourceId });
2323

2424
const config = useMemo(() => {
25-
if (!source) {
25+
if (!source || !traceId) {
2626
return;
2727
}
2828
return {
@@ -54,10 +54,10 @@ export const useSessionId = ({
5454
}, [source, traceId]);
5555

5656
const { data } = useEventsData({
57-
config: config!, // ok to force unwrap, the query will be disabled if source is null
57+
config: config!, // ok to force unwrap, the query will be disabled if config is null
5858
dateRangeStartInclusive: true,
5959
dateRange,
60-
enabled: enabled && !!source,
60+
enabled: enabled && !!source && !!config,
6161
});
6262

6363
const result = useMemo(() => {

packages/app/src/components/DBTracePanel.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useForm } from 'react-hook-form';
44
import { tcFromSource } from '@hyperdx/common-utils/dist/core/metadata';
55
import { SourceKind } from '@hyperdx/common-utils/dist/types';
66
import {
7-
Badge,
87
Button,
98
Center,
109
Divider,
@@ -19,7 +18,6 @@ import { DBTraceWaterfallChartContainer } from '@/components/DBTraceWaterfallCha
1918
import { useSource, useUpdateSource } from '@/source';
2019
import TabBar from '@/TabBar';
2120

22-
import ServiceMap from './ServiceMap/ServiceMap';
2321
import { RowDataPanel } from './DBRowDataPanel';
2422
import { RowOverviewPanel } from './DBRowOverviewPanel';
2523
import { SourceSelectControlled } from './SourceSelect';
@@ -41,7 +39,7 @@ export default function DBTracePanel({
4139
}: {
4240
parentSourceId?: string | null;
4341
childSourceId?: string | null;
44-
traceId: string;
42+
traceId?: string;
4543
dateRange: [Date, Date];
4644
focusDate: Date;
4745
// Passed in from side panel to try to identify which
@@ -54,7 +52,7 @@ export default function DBTracePanel({
5452
};
5553
'data-testid'?: string;
5654
}) {
57-
const { control, watch, setValue } = useForm({
55+
const { control, watch } = useForm({
5856
defaultValues: {
5957
source: childSourceId,
6058
},
@@ -192,7 +190,7 @@ export default function DBTracePanel({
192190
</Stack>
193191
)}
194192
<Divider my="sm" />
195-
{traceSourceData?.kind === SourceKind.Trace && (
193+
{traceSourceData?.kind === SourceKind.Trace && traceId && (
196194
<DBTraceWaterfallChartContainer
197195
traceTableSource={traceSourceData}
198196
logTableSource={logSourceData}
@@ -246,7 +244,7 @@ export default function DBTracePanel({
246244
)}
247245
</>
248246
)}
249-
{traceSourceData != null && !eventRowWhere && (
247+
{traceSourceData != null && !eventRowWhere && traceId && (
250248
<Paper shadow="xs" p="xl" mt="md">
251249
<Center mih={100}>
252250
<Text size="sm">Please select a span above to view details.</Text>

0 commit comments

Comments
 (0)