:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(experiments): time out stuck metric loads instead of spinning forever (#118304)
posthog[bot]ac8aec5b5867
diff --git a/frontend/src/scenes/experiments/experimentMetricsLogic.test.ts b/frontend/src/scenes/experiments/experimentMetricsLogic.test.tsindex d0bcae8bc188..bc52d42bcbc8 100644--- a/frontend/src/scenes/experiments/experimentMetricsLogic.test.ts+++ b/frontend/src/scenes/experiments/experimentMetricsLogic.test.ts@@ -1,4 +1,5 @@import { expectLogic } from 'kea-test-utils'+import posthog from 'posthog-js'import { lemonToast } from '@posthog/lemon-ui'@@ -25,6 +26,12 @@ jest.mock('@posthog/lemon-ui', () => ({const POLL_INTERVAL_MS = 2000// Mirrors the private MAX_POLL_RETRIES in experimentMetricsLogic.const MAX_POLL_RETRIES = 5+// Mirror the private request deadlines in experimentMetricsLogic.+const LATEST_REQUEST_TIMEOUT_MS = 30 * 1000+const POLL_REQUEST_TIMEOUT_MS = 15 * 1000++const SLOW_LOAD_MESSAGE = 'Loading results is taking longer than expected. Refresh the results to try again.'+const neverSettles = (): Promise<never> => new Promise(() => {})const EXPERIMENT = experimentJson as unknown as Experimentconst PRIMARY_METRIC_UUID = '434cb6ba-7fa6-4ca1-b7a0-8970b2d9a47d'@@ -380,6 +387,34 @@ describe('experimentMetricsLogic', () => {expect(logic.values.recalculationLoading).toBe(false)})+ it('stops loading and offers a retry when the latest request never settles', async () => {+ const captureSpy = jest.spyOn(posthog, 'capture')+ useMocks({+ get: {+ '/api/projects/:team_id/experiments/:id/metrics_recalculation/latest/': neverSettles,+ },+ })+ jest.useFakeTimers()+ try {+ mountLogic()+ await jest.advanceTimersByTimeAsync(LATEST_REQUEST_TIMEOUT_MS)++ expect(logic.values.recalculationLoading).toBe(false)+ expect(logic.values.isRecalculating).toBe(false)+ const retryable = { detail: SLOW_LOAD_MESSAGE, retriable: true }+ expect(logic.values.primaryMetricsResultsErrors).toEqual([retryable, retryable])+ expect(logic.values.secondaryMetricsResultsErrors).toEqual([retryable, retryable])+ expect(lemonToast.error).toHaveBeenCalledWith(SLOW_LOAD_MESSAGE)+ expect(captureSpy).toHaveBeenCalledWith(+ 'experiment metric recalculation',+ expect.objectContaining({ status: 'abandoned', reason: 'latest_timeout' })+ )+ } finally {+ captureSpy.mockRestore()+ jest.useRealTimers()+ }+ })+it('triggers a cold_run recalculation when latest returns 404', async () => {let capturedBody: anyuseMocks({@@ -556,6 +591,9 @@ describe('experimentMetricsLogic', () => {await jest.advanceTimersByTimeAsync(POLL_INTERVAL_MS * 5)expect(retrieveMock).not.toHaveBeenCalled()expect(logic.values.recalculatingMetricUuids).toEqual([])+ // The run's status is still in_progress, but the page must not keep showing it as loading.+ expect(logic.values.isRecalculating).toBe(false)+ expect(logic.values.recalculationDisplayState).toBe('resting')jest.useRealTimers()})@@ -1228,43 +1266,69 @@ describe('experimentMetricsLogic', () => {expect(logic.values.primaryMetricsResultsErrors[0]).toEqual({ detail: 'boom', retriable: false })})- it('gives up after MAX_POLL_RETRIES consecutive retrieve failures', async () => {- let retrieveCalls = 0- useMocks({- get: {- '/api/projects/:team_id/experiments/:id/metrics_recalculation/latest/': () => [404, {}],- '/api/projects/:team_id/experiments/:id/metrics_recalculation/:recalc_id/': () => {- retrieveCalls += 1- return [500, {}]+ it.each([+ {+ name: 'failures',+ respond: () => [500, {}],+ tickMs: POLL_INTERVAL_MS,+ reason: 'poll_failed',+ message: "Couldn't load the recalculation results. Refresh the results to try again.",+ },+ {+ name: 'requests that never settle',+ respond: neverSettles,+ tickMs: POLL_INTERVAL_MS + POLL_REQUEST_TIMEOUT_MS,+ reason: 'poll_timeout',+ message: SLOW_LOAD_MESSAGE,+ },+ ])(+ 'gives up after MAX_POLL_RETRIES consecutive retrieve $name',+ async ({ respond, tickMs, reason, message }) => {+ const captureSpy = jest.spyOn(posthog, 'capture')+ let retrieveCalls = 0+ useMocks({+ get: {+ '/api/projects/:team_id/experiments/:id/metrics_recalculation/latest/': () => [404, {}],+ '/api/projects/:team_id/experiments/:id/metrics_recalculation/:recalc_id/': () => {+ retrieveCalls += 1+ return respond()+ },},- },- post: {- '/api/projects/:team_id/experiments/:id/metrics_recalculation/': () => [- 201,- inProgressRecalculation,- ],- },- })- jest.useFakeTimers()- mountLogic()+ post: {+ '/api/projects/:team_id/experiments/:id/metrics_recalculation/': () => [+ 201,+ inProgressRecalculation,+ ],+ },+ })+ jest.useFakeTimers()+ mountLogic()- // Flush afterMount → 404 → trigger → poll(create), then drive enough ticks to exhaust retries.- await jest.advanceTimersByTimeAsync(0)- // A config change queued a rerun while the run was in flight.- logic.actions.setQueuedRerun('metric_config_change')- for (let i = 0; i < MAX_POLL_RETRIES + 2; i++) {- await jest.advanceTimersByTimeAsync(POLL_INTERVAL_MS)- }+ // Flush afterMount → 404 → trigger → poll(create), then drive enough ticks to exhaust retries.+ await jest.advanceTimersByTimeAsync(0)+ // A config change queued a rerun while the run was in flight.+ logic.actions.setQueuedRerun('metric_config_change')+ for (let i = 0; i < MAX_POLL_RETRIES + 2; i++) {+ await jest.advanceTimersByTimeAsync(tickMs)+ }- // Stops retrieving once the cap is hit and surfaces an error; never loops forever.- expect(retrieveCalls).toBe(MAX_POLL_RETRIES)- expect(lemonToast.error).toHaveBeenCalledWith(- 'Failed to load recalculation results. Please reload to try again.'- )- // The bail clears the queued rerun so it can't strand: the terminal branch (its only consumer)- // never runs on a give-up path.- expect(logic.values.queuedRerun).toBeNull()- })+ // Stops retrieving once the cap is hit and surfaces an error; never loops forever.+ expect(retrieveCalls).toBe(MAX_POLL_RETRIES)+ expect(lemonToast.error).toHaveBeenCalledWith(message)+ // The bail clears the queued rerun so it can't strand: the terminal branch (its only consumer)+ // never runs on a give-up path.+ expect(logic.values.queuedRerun).toBeNull()+ // The run is still in_progress server-side, but the page stops loading and each metric offers a retry.+ expect(logic.values.isRecalculating).toBe(false)+ const retryable = { detail: message, retriable: true }+ expect(logic.values.primaryMetricsResultsErrors).toEqual([retryable, retryable])+ expect(captureSpy).toHaveBeenCalledWith(+ 'experiment metric recalculation',+ expect.objectContaining({ status: 'abandoned', reason, recalculation_id: 'recalc-2' })+ )+ captureSpy.mockRestore()+ }+ )it('on a cold_run, applies partial results mid-flight before the run is terminal', async () => {useMocks({diff --git a/frontend/src/scenes/experiments/experimentMetricsLogic.ts b/frontend/src/scenes/experiments/experimentMetricsLogic.tsindex 6c49a7eb59ef..f6b32ee6caa4 100644--- a/frontend/src/scenes/experiments/experimentMetricsLogic.ts+++ b/frontend/src/scenes/experiments/experimentMetricsLogic.ts@@ -28,8 +28,14 @@ import type {import { type ExperimentSavedMetric, sharedMetricsToExperimentMetrics } from './utils'+/**+ * Why a load stopped waiting and showed a retryable error instead. Each one emits an `abandoned` event, the+ * only signal a hung load leaves.+ */+export type RecalculationAbandonReason = 'latest_timeout' | 'poll_timeout' | 'poll_failed' | 'poll_duration_cap'+function reportExperimentMetricRecalculation(- status: 'triggered' | 'completed' | 'failed',+ status: 'triggered' | 'completed' | 'failed' | 'abandoned',properties: {experiment_id: numberrecalculation_id: string | null@@ -40,6 +46,7 @@ function reportExperimentMetricRecalculation(failed?: numberduration_ms?: numberpoll_count?: number+ reason?: RecalculationAbandonReason}): void {posthog.capture('experiment metric recalculation', { status, ...properties })@@ -73,6 +80,39 @@ const MAX_POLL_RETRIES = 5* this cap every tab that resumed the run would poll its id (and the per-tick live-progress query) forever.*/const MAX_POLL_DURATION_MS = 30 * 60 * 1000+// A request that never settles neither resolves nor rejects, so without a deadline the page loads forever.+const LATEST_REQUEST_TIMEOUT_MS = 30 * 1000+const POLL_REQUEST_TIMEOUT_MS = 15 * 1000++class RecalculationRequestTimeoutError extends Error {}++/**+ * Rejects with RecalculationRequestTimeoutError after `timeoutMs` and aborts the request. The race settles the+ * call even if the transport ignores the abort signal.+ */+async function withRequestTimeout<T>(request: (signal: AbortSignal) => Promise<T>, timeoutMs: number): Promise<T> {+ const controller = new AbortController()+ let timerId: ReturnType<typeof setTimeout> | undefined+ const deadline = new Promise<never>((_, reject) => {+ timerId = setTimeout(() => {+ reject(new RecalculationRequestTimeoutError(`Request timed out after ${timeoutMs}ms`))+ controller.abort()+ }, timeoutMs)+ })+ try {+ return await Promise.race([request(controller.signal), deadline])+ } finally {+ clearTimeout(timerId)+ }+}++const SLOW_LOAD_MESSAGE = 'Loading results is taking longer than expected. Refresh the results to try again.'+const ABANDON_MESSAGES: Record<RecalculationAbandonReason, string> = {+ latest_timeout: SLOW_LOAD_MESSAGE,+ poll_timeout: SLOW_LOAD_MESSAGE,+ poll_duration_cap: SLOW_LOAD_MESSAGE,+ poll_failed: "Couldn't load the recalculation results. Refresh the results to try again.",+}export const RECALCULATION_STATUSES = {pending: 'pending',@@ -231,6 +271,7 @@ export interface experimentMetricsLogicValues {primaryMetricsResultsErrors: (unknown | null)[]queuedRerun: ExperimentMetricsRecalculationRequestTriggerEnumApi | nullrecalculatingMetricUuids: string[]+ recalculationAbandoned: booleanrecalculationDisplayState: 'cold' | 'initial' | 'partial' | 'refreshing' | 'resting'recalculationLoading: booleanrecalculationProgress: {@@ -245,6 +286,13 @@ export interface experimentMetricsLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface experimentMetricsLogicActions {+ abandonRecalculation: (+ reason: RecalculationAbandonReason,+ recalculationId: string | null+ ) => {+ reason: RecalculationAbandonReason+ recalculationId: string | null+ }loadLatestRecalculation: () => {value: true}@@ -290,7 +338,11 @@ export interface experimentMetricsLogicActions {export interface experimentMetricsLogicMeta {key: ExperimentIdType__keaTypeGenInternalSelectorTypes: {- isRecalculating: (recalculationLoading: boolean, currentRecalculation: RecalculationPayload | null) => boolean+ isRecalculating: (+ recalculationLoading: boolean,+ currentRecalculation: RecalculationPayload | null,+ recalculationAbandoned: boolean+ ) => booleanrecalculationProgress: (currentRecalculation: RecalculationPayload | null) => {completed: numbertotal: number@@ -307,7 +359,8 @@ export interface experimentMetricsLogicMeta {nextRetryAt: (metricRetries: Record<string, MetricRetryInfo>) => string | nullrecalculationDisplayState: (recalculationLoading: boolean,- currentRecalculation: RecalculationPayload | null+ currentRecalculation: RecalculationPayload | null,+ recalculationAbandoned: boolean) => 'cold' | 'initial' | 'partial' | 'refreshing' | 'resting'isMetricRecalculating: (recalculatingMetricUuids: string[]) => (metricUuid: string | undefined) => boolean}@@ -344,6 +397,10 @@ export const experimentMetricsLogic = kea<experimentMetricsLogicType>([// The metrics still showing a stale value while a non-cold recalc refreshes them in place.setRecalculatingMetricUuids: (uuids: string[]) => ({ uuids }),setQueuedRerun: (trigger: ExperimentMetricsRecalculationRequestTriggerEnumApi | null) => ({ trigger }),+ abandonRecalculation: (reason: RecalculationAbandonReason, recalculationId: string | null) => ({+ reason,+ recalculationId,+ }),}),reducers({currentRecalculation: [@@ -360,6 +417,15 @@ export const experimentMetricsLogic = kea<experimentMetricsLogicType>([setCurrentRecalculation: () => false,},],+ // The page stopped waiting on the current run, so its pending or in_progress status no longer means loading.+ recalculationAbandoned: [+ false,+ {+ abandonRecalculation: () => true,+ loadLatestRecalculation: () => false,+ setCurrentRecalculation: () => false,+ },+ ],// Bumped when the manual refresh window closes, so isManualRefreshBlocked recomputes without new data.refreshEligibilityTick: [0, { recheckRefreshEligibility: (state: number) => state + 1 }],// A 429 proves the backend enforces the window, even when this page's cached flags still say otherwise.@@ -427,11 +493,16 @@ export const experimentMetricsLogic = kea<experimentMetricsLogicType>([selectors({// True while a recalculation is being fetched or is still running.isRecalculating: [- (s) => [s.recalculationLoading, s.currentRecalculation],- (recalculationLoading: boolean, recalculation: RecalculationPayload | null): boolean =>+ (s) => [s.recalculationLoading, s.currentRecalculation, s.recalculationAbandoned],+ (+ recalculationLoading: boolean,+ recalculation: RecalculationPayload | null,+ recalculationAbandoned: boolean+ ): boolean =>recalculationLoading ||- recalculation?.status === RECALCULATION_STATUSES.pending ||- recalculation?.status === RECALCULATION_STATUSES.in_progress,+ (!recalculationAbandoned &&+ (recalculation?.status === RECALCULATION_STATUSES.pending ||+ recalculation?.status === RECALCULATION_STATUSES.in_progress)),],recalculationProgress: [(s) => [s.currentRecalculation],@@ -493,18 +564,20 @@ export const experimentMetricsLogic = kea<experimentMetricsLogicType>([},],recalculationDisplayState: [- (s) => [s.recalculationLoading, s.currentRecalculation],+ (s) => [s.recalculationLoading, s.currentRecalculation, s.recalculationAbandoned],(recalculationLoading: boolean,- recalculation: RecalculationPayload | null+ recalculation: RecalculationPayload | null,+ recalculationAbandoned: boolean): 'initial' | 'cold' | 'refreshing' | 'partial' | 'resting' => {if (!recalculation) {return recalculationLoading ? 'initial' : 'resting'}const inFlight =recalculationLoading ||- recalculation.status === RECALCULATION_STATUSES.pending ||- recalculation.status === RECALCULATION_STATUSES.in_progress+ (!recalculationAbandoned &&+ (recalculation.status === RECALCULATION_STATUSES.pending ||+ recalculation.status === RECALCULATION_STATUSES.in_progress))if (inFlight) {return (recalculation.results?.length ?? 0) > 0 ? 'refreshing' : 'cold'}@@ -557,6 +630,28 @@ export const experimentMetricsLogic = kea<experimentMetricsLogicType>([)}+ /**+ * Gives every metric with neither a result nor an error a retryable error. Without one, the row reads as+ * loading (no result, no error) for as long as the page stays open.+ */+ const markUnresolvedMetricsRetriable = (detail: string): void => {+ const error: MetricErrorState = { detail, retriable: true }+ const withRetriableErrors = (+ type: 'primary' | 'secondary',+ results: readonly (CachedNewExperimentQueryResponse | undefined)[],+ errors: readonly (unknown | null)[]+ ): (unknown | null)[] =>+ metricsInOrder(props.experiment, type).map(+ (_, index) => errors[index] ?? (results[index] ? null : error)+ )+ actions.setPrimaryMetricsResultsErrors(+ withRetriableErrors('primary', values.primaryMetricsResults, values.primaryMetricsResultsErrors)+ )+ actions.setSecondaryMetricsResultsErrors(+ withRetriableErrors('secondary', values.secondaryMetricsResults, values.secondaryMetricsResultsErrors)+ )+ }+const applyResults = (recalculation: RecalculationPayload): void => {const resultFor = resolveResultByUuid(recalculation.results)const errorFor = resolveErrorByUuid(recalculation)@@ -647,9 +742,10 @@ export const experimentMetricsLogic = kea<experimentMetricsLogicType>([* retrieve the latest complete recalculation so we always show results, even if stale.* store it in state and apply the results.*/- const recalculation = await experimentsMetricsRecalculationLatestRetrieve(- String(projectId),- experimentId+ const recalculation = await withRequestTimeout(+ (signal) =>+ experimentsMetricsRecalculationLatestRetrieve(String(projectId), experimentId, { signal }),+ LATEST_REQUEST_TIMEOUT_MS)if (cache.disposables.isDisposed) {return@@ -700,14 +796,38 @@ export const experimentMetricsLogic = kea<experimentMetricsLogicType>([actions.triggerRecalculation('cold_run')return}+ if (error instanceof RecalculationRequestTimeoutError) {+ actions.abandonRecalculation('latest_timeout', null)+ return+ }- lemonToast.error('Failed to load latest recalculation')+ lemonToast.error("Couldn't load experiment results. Refresh the results to try again.")+ markUnresolvedMetricsRetriable("Couldn't load results for this metric.")} finally {if (!cache.disposables.isDisposed) {actions.setRecalculationLoading(false)}}},+ abandonRecalculation: ({ reason, recalculationId }) => {+ actions.setRecalculatingMetricUuids([])+ // A queued rerun drains only when a poll reaches terminal, which no longer happens.+ actions.setQueuedRerun(null)+ actions.setRecalculationLoading(false)+ markUnresolvedMetricsRetriable(ABANDON_MESSAGES[reason])+ lemonToast.error(ABANDON_MESSAGES[reason])+ reportExperimentMetricRecalculation('abandoned', {+ experiment_id: props.experiment.id as number,+ recalculation_id: recalculationId,+ reason,+ ...(recalculationId+ ? {+ duration_ms: Date.now() - (cache.recalcStartMs ?? Date.now()),+ poll_count: cache.pollCount ?? 0,+ }+ : {}),+ })+ },setCurrentRecalculation: () => {// Re-enable the reload button the moment the window closes, not on the next data load.cache.disposables.dispose('manualRefreshEligibility')@@ -744,7 +864,8 @@ export const experimentMetricsLogic = kea<experimentMetricsLogicType>([*/const runStatus = values.currentRecalculation?.statusconst runInFlight =- runStatus === RECALCULATION_STATUSES.pending || runStatus === RECALCULATION_STATUSES.in_progress+ !values.recalculationAbandoned &&+ (runStatus === RECALCULATION_STATUSES.pending || runStatus === RECALCULATION_STATUSES.in_progress)if ((trigger === 'experiment_config_change' || trigger === 'metric_config_change') &&(runInFlight || cache.createInFlight)@@ -897,9 +1018,7 @@ export const experimentMetricsLogic = kea<experimentMetricsLogicType>([* be fired.*/if (Date.now() - (cache.recalcStartMs ?? Date.now()) > MAX_POLL_DURATION_MS) {- actions.setRecalculatingMetricUuids([])- actions.setQueuedRerun(null)- lemonToast.error('Recalculation appears stuck. Please reload to try again.')+ actions.abandonRecalculation('poll_duration_cap', recalculationId)return}@@ -908,21 +1027,29 @@ export const experimentMetricsLogic = kea<experimentMetricsLogicType>([let recalculation: ExperimentMetricsRecalculationRunApitry {- recalculation = await experimentsMetricsRecalculationRetrieve(- String(projectId),- experimentId,- recalculationId+ recalculation = await withRequestTimeout(+ (signal) =>+ experimentsMetricsRecalculationRetrieve(String(projectId), experimentId, recalculationId, {+ signal,+ }),+ POLL_REQUEST_TIMEOUT_MS)- } catch {+ } catch (error) {+ // A slow request can outlive a newer poll; don't count or abandon on behalf of a superseded run.+ breakpoint()+ if (cache.activeRecalculationId !== recalculationId) {+ return+ }/**- * Retry on transient errors, but give up after MAX_POLL_RETRIES consecutive failures so a- * persistently failing endpoint can't poll forever.- * If we reach the retry cap, we also need to clear queued reruns that never fire.+ * Retry on transient errors and timeouts, but give up after MAX_POLL_RETRIES consecutive+ * failures so a persistently failing endpoint can't poll forever.*/cache.pollRetryCount = (cache.pollRetryCount ?? 0) + 1if (cache.pollRetryCount >= MAX_POLL_RETRIES) {- actions.setQueuedRerun(null)- lemonToast.error('Failed to load recalculation results. Please reload to try again.')+ actions.abandonRecalculation(+ error instanceof RecalculationRequestTimeoutError ? 'poll_timeout' : 'poll_failed',+ recalculationId+ )return}actions.pollRecalculation(recalculationId)diff --git a/frontend/src/scenes/experiments/experimentResultsNotificationLogic.test.ts b/frontend/src/scenes/experiments/experimentResultsNotificationLogic.test.tsindex a0e44dee0804..c7beea3d903f 100644--- a/frontend/src/scenes/experiments/experimentResultsNotificationLogic.test.ts+++ b/frontend/src/scenes/experiments/experimentResultsNotificationLogic.test.ts@@ -66,6 +66,29 @@ describe('experimentResultsNotificationLogic', () => {expect(logic.values.notifyWhenResultsReady).toBe(false)})+ it('does not announce results when the page abandons the run, and drops the subscription', async () => {+ const notificationSpy = jest.fn()+ Object.defineProperty(window, 'Notification', {+ value: Object.assign(notificationSpy, { permission: 'granted' }),+ configurable: true,+ })+ try {+ // The seeded run has a gap, so mount also fires a heal request; let it land before driving the edge.+ await expectLogic(metricsLogic).toFinishAllListeners()+ metricsLogic.actions.setCurrentRecalculation({ id: 'x', status: 'in_progress' } as any)+ logic.actions.setNotifyWhenResultsReady(true)++ metricsLogic.actions.abandonRecalculation('poll_timeout', 'x')++ expect(notificationSpy).not.toHaveBeenCalled()+ expect(logic.values.notifyWhenResultsReady).toBe(false)+ expect(dispatchBeforeUnload()).toBe(false)+ } finally {+ // jsdom has no Notification; leaving the key would make `'Notification' in window` true elsewhere.+ delete (window as any).Notification+ }+ })+it('warns before unload while subscribed and stops once results land', async () => {metricsLogic.actions.setCurrentRecalculation({ id: 'x', status: 'in_progress' } as any)expect(dispatchBeforeUnload()).toBe(false)diff --git a/frontend/src/scenes/experiments/experimentResultsNotificationLogic.ts b/frontend/src/scenes/experiments/experimentResultsNotificationLogic.tsindex 915529923d1e..282d53251661 100644--- a/frontend/src/scenes/experiments/experimentResultsNotificationLogic.ts+++ b/frontend/src/scenes/experiments/experimentResultsNotificationLogic.ts@@ -15,6 +15,7 @@ export interface ExperimentResultsNotificationLogicProps {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface experimentResultsNotificationLogicValues {isRecalculating: boolean // experimentMetricsLogic+ recalculationAbandoned: boolean // experimentMetricsLogicnotifyWhenResultsReady: boolean}@@ -53,7 +54,10 @@ export const experimentResultsNotificationLogic = kea<experimentResultsNotificatkey((props) => props.experiment.id),path((key) => ['scenes', 'experiment', 'experimentResultsNotificationLogic', String(key)]),connect((props: ExperimentResultsNotificationLogicProps) => ({- values: [experimentMetricsLogic({ experiment: props.experiment }), ['isRecalculating']],+ values: [+ experimentMetricsLogic({ experiment: props.experiment }),+ ['isRecalculating', 'recalculationAbandoned'],+ ],})),actions({setNotifyWhenResultsReady: (notify: boolean) => ({ notify }),@@ -132,9 +136,14 @@ export const experimentResultsNotificationLogic = kea<experimentResultsNotificat* experimentMetricsLogic. There's no single action whose handler cleanly expresses "the derived value* just flipped", so this is the skill's sanctioned subscriptions case.*/- subscriptions(({ actions }) => ({+ subscriptions(({ actions, values }) => ({isRecalculating: (isRecalculating: boolean, previous: boolean | undefined) => {if (!isRecalculating && previous) {+ // An abandoned load stops loading without results, so there is nothing ready to announce.+ if (values.recalculationAbandoned) {+ actions.setNotifyWhenResultsReady(false)+ return+ }actions.notifyResultsReady()}},