Skip to content

: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.

fix(aio): keep the table when a renderer chunk fails after a reload (#110351)

Paul D'Ambra986e737d47d7
diff --git a/products/ai_observability/frontend/AIObservabilityGlobalColumnCell.test.tsx b/products/ai_observability/frontend/AIObservabilityGlobalColumnCell.test.tsx
new file mode 100644
index 000000000000..d98d493f22b0
--- /dev/null
+++ b/products/ai_observability/frontend/AIObservabilityGlobalColumnCell.test.tsx
@@ -0,0 +1,64 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen } from '@testing-library/react'
+import { Component, type ReactNode } from 'react'
+
+import { DataTableNode, NodeKind } from '~/queries/schema/schema-general'
+
+import { AIObservabilityGlobalColumnCell } from './AIObservabilityGlobalColumnCell'
+
+jest.mock('./aiObservabilityColumnRenderers', () => {
+ throw new TypeError('Failed to fetch dynamically imported module: /static/aiObservabilityColumnRenderers.js')
+})
+
+class TableErrorBoundary extends Component<{ children: ReactNode }, { failed: boolean }> {
+ override state = { failed: false }
+
+ static getDerivedStateFromError(): { failed: boolean } {
+ return { failed: true }
+ }
+
+ override render(): ReactNode {
+ return this.state.failed ? <div>table replaced by an error</div> : this.props.children
+ }
+}
+
+const query: DataTableNode = { kind: NodeKind.DataTableNode, source: { kind: NodeKind.EventsQuery, select: ['*'] } }
+
+describe('AIObservabilityGlobalColumnCell', () => {
+ let consoleErrorSpy: jest.SpyInstance
+ let consoleWarnSpy: jest.SpyInstance
+
+ beforeEach(() => {
+ // Another cell's boundary already reloaded for this chunk, so the guard stops a second reload.
+ window.localStorage.setItem('posthog-chunk-reload-at', String(Date.now()))
+ consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
+ consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {})
+ })
+
+ afterEach(() => {
+ window.localStorage.clear()
+ consoleErrorSpy.mockRestore()
+ consoleWarnSpy.mockRestore()
+ cleanup()
+ })
+
+ it('keeps the table on screen when the renderer chunk fails after a reload', async () => {
+ render(
+ <TableErrorBoundary>
+ <AIObservabilityGlobalColumnCell
+ rendererKey="properties.$ai_trace_id"
+ columnName="properties.$ai_trace_id"
+ query={query}
+ record={{}}
+ recordIndex={0}
+ rowCount={1}
+ value="trace-1"
+ />
+ </TableErrorBoundary>
+ )
+
+ expect(await screen.findByText('Error', {}, { timeout: 3000 })).toBeInTheDocument()
+ expect(screen.queryByText('table replaced by an error')).not.toBeInTheDocument()
+ })
+})
diff --git a/products/ai_observability/frontend/AIObservabilityGlobalColumnCell.tsx b/products/ai_observability/frontend/AIObservabilityGlobalColumnCell.tsx
index 8a7b90ec9fde..1d95f79ba86c 100644
--- a/products/ai_observability/frontend/AIObservabilityGlobalColumnCell.tsx
+++ b/products/ai_observability/frontend/AIObservabilityGlobalColumnCell.tsx
@@ -1,5 +1,6 @@
import { ComponentProps, Suspense } from 'react'
+import { LemonTag } from 'lib/lemon-ui/LemonTag/LemonTag'
import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'
import { lazyWithRetry } from 'lib/utils/retryImport'
import { ChunkLoadErrorBoundary } from 'scenes/ChunkLoadErrorBoundary'
@@ -20,7 +21,9 @@ const RendererCell = lazyWithRetry(() =>
export function AIObservabilityGlobalColumnCell(props: CellProps): JSX.Element {
return (
// The query's own ErrorBoundary is nearer than the scene's, so without this a stale chunk never reloads.
- <ChunkLoadErrorBoundary>
+ // Every cell catches the same failed chunk, and the reload guard stops all but the first, so the
+ // others show the cell error tag instead of replacing the table.
+ <ChunkLoadErrorBoundary fallback={() => <LemonTag className="text-danger">Error</LemonTag>}>
<Suspense fallback={<Spinner />}>
<RendererCell {...props} />
</Suspense>