SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: update panel waiting state condition (#10702)
Ashwin Bhatkalc23c6c8c276f
diff --git a/frontend/src/hooks/dashboard/__test__/useIsPanelWaitingOnVariable.test.ts b/frontend/src/hooks/dashboard/__test__/useIsPanelWaitingOnVariable.test.tsindex 814b9f8072..a4662ca6d8 100644--- a/frontend/src/hooks/dashboard/__test__/useIsPanelWaitingOnVariable.test.ts+++ b/frontend/src/hooks/dashboard/__test__/useIsPanelWaitingOnVariable.test.ts@@ -137,7 +137,7 @@ describe('useIsPanelWaitingOnVariable', () => {expect(result.current).toBe(false);});- it('should return true for DYNAMIC variable with allSelected=true that is loading', () => {+ it('should return false for DYNAMIC variable with allSelected=true that is loading but has a selectedValue', () => {setFetchStates({ dyn: 'loading' });setDashboardVariables({variables: {@@ -152,10 +152,10 @@ describe('useIsPanelWaitingOnVariable', () => {});const { result } = renderHook(() => useIsPanelWaitingOnVariable(['dyn']));- expect(result.current).toBe(true);+ expect(result.current).toBe(false);});- it('should return true for DYNAMIC variable with allSelected=true that is waiting', () => {+ it('should return false for DYNAMIC variable with allSelected=true that is waiting but has a selectedValue', () => {setFetchStates({ dyn: 'waiting' });setDashboardVariables({variables: {@@ -170,7 +170,7 @@ describe('useIsPanelWaitingOnVariable', () => {});const { result } = renderHook(() => useIsPanelWaitingOnVariable(['dyn']));- expect(result.current).toBe(true);+ expect(result.current).toBe(false);});it('should return false for DYNAMIC variable with allSelected=true that is idle', () => {@@ -313,4 +313,39 @@ describe('useIsPanelWaitingOnVariable', () => {const { result } = renderHook(() => useIsPanelWaitingOnVariable(['a']));expect(result.current).toBe(true);});++ it('should find variable by name when store key differs from variable name', () => {+ setFetchStates({ myVar: 'loading' });+ setDashboardVariables({+ variables: {+ 'uuid-abc-123': makeVariable({+ id: 'uuid-abc-123',+ name: 'myVar',+ selectedValue: undefined,+ }),+ },+ variableTypes: { myVar: 'QUERY' },+ });++ const { result } = renderHook(() => useIsPanelWaitingOnVariable(['myVar']));+ expect(result.current).toBe(true);+ });++ it('should respect selectedValue when store key differs from variable name', () => {+ // When the variable has a value, it should not block even if loading+ setFetchStates({ myVar: 'loading' });+ setDashboardVariables({+ variables: {+ 'uuid-abc-123': makeVariable({+ id: 'uuid-abc-123',+ name: 'myVar',+ selectedValue: 'production',+ }),+ },+ variableTypes: { myVar: 'QUERY' },+ });++ const { result } = renderHook(() => useIsPanelWaitingOnVariable(['myVar']));+ expect(result.current).toBe(false);+ });});diff --git a/frontend/src/hooks/dashboard/useVariableFetchState.ts b/frontend/src/hooks/dashboard/useVariableFetchState.tsindex 8e17eafcaf..93d6cf1fdc 100644--- a/frontend/src/hooks/dashboard/useVariableFetchState.ts+++ b/frontend/src/hooks/dashboard/useVariableFetchState.ts@@ -133,21 +133,19 @@ export function useVariableFetchState(export function useIsPanelWaitingOnVariable(variableNames: string[]): boolean {const states = useVariableFetchSelector((s) => s.states);const dashboardVariables = useDashboardVariablesSelector((s) => s.variables);- const variableTypesMap = useDashboardVariablesSelector((s) => s.variableTypes);return variableNames.some((name) => {const variableFetchState = states[name];- const { selectedValue, allSelected } = dashboardVariables?.[name] || {};+ const variableData = Object.values(dashboardVariables).find(+ (v) => v.name === name,+ );+ const { selectedValue } = variableData || {};const isVariableInFetchingOrWaitingState =variableFetchState === 'loading' ||variableFetchState === 'revalidating' ||variableFetchState === 'waiting';- if (variableTypesMap[name] === 'DYNAMIC' && allSelected) {- return isVariableInFetchingOrWaitingState;- }-return isEmpty(selectedValue) ? isVariableInFetchingOrWaitingState : false;});}