fix: stop localmode premature fetches & discover existing sources during onboarding (#1811)

In localmode and the clickhouse build, it is common to hit a scenario where a connection is not defined, but sources are. This causes the search page to start spamming queries without any credentials, which causes the browser to repeatedly show a prompt for auth credentials and kills the whole onboarding process. Additionally, after creating a connection in the onboarding modal, the sources were not discovered by the onboarding modal and would force you to redefine a source even though you had some saved. This PR fixes both of those issues.

Closes HDX-3515
Closes HDX-3516
This commit is contained in:
Aaron Knudtson 2026-02-26 14:20:03 -05:00 committed by GitHub
parent a6edb0dd4c
commit 578b1eea9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 1 deletions

View file

@ -0,0 +1,6 @@
---
"@hyperdx/app": patch
---
fix: localmode stops prematurely fetching data
fix: users do not have to keep defining sources during onboarding modal if they already have sources

View file

@ -234,6 +234,18 @@ function OnboardingModalComponent({
setStep(startStep);
}
}, [startStep, step]);
useEffect(() => {
if (
(step === 'auto-detect' || step === 'source') &&
sources &&
sources.length > 0
) {
// Sources may load in late once a connection is defined.
// If this happens, close the modal, we don't want to bother the user
// by forcing redefining their sources
setStep('closed');
}
}, [step, sources]);
const createSourceMutation = useCreateSource();
const createConnectionMutation = useCreateConnection();

View file

@ -97,6 +97,7 @@ export function useCreateConnection() {
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['connections'] });
queryClient.invalidateQueries({ queryKey: ['sources'] });
},
});
}

View file

@ -27,6 +27,8 @@ import { HDX_LOCAL_DEFAULT_SOURCES } from '@/config';
import { IS_LOCAL_MODE } from '@/config';
import { parseJSON } from '@/utils';
import { getLocalConnections } from './connection';
// Columns for the sessions table as of OTEL Collector v0.129.1
export const SESSION_TABLE_EXPRESSIONS = {
resourceAttributesExpression: 'ResourceAttributes',
@ -47,7 +49,8 @@ function setLocalSources(fn: (prev: TSource[]) => TSource[]) {
}
function getLocalSources(): TSource[] {
if (store.has(LOCAL_STORE_SOUCES_KEY)) {
const connections = getLocalConnections();
if (connections.length > 0 && store.has(LOCAL_STORE_SOUCES_KEY)) {
return store.get(LOCAL_STORE_SOUCES_KEY, []) ?? [];
}
// pull sources from env var