: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(frontend): retry transient chunk-load failures for lazy imports (#68897)
Marcel Poelker5fd0e6b94321
diff --git a/frontend/src/exporter/Exporter.tsx b/frontend/src/exporter/Exporter.tsxindex a2b8401df6dc..76806b21c1d7 100644--- a/frontend/src/exporter/Exporter.tsx+++ b/frontend/src/exporter/Exporter.tsx@@ -3,7 +3,7 @@ import './Exporter.scss'import clsx from 'clsx'import { BindLogic, useValues } from 'kea'-import { lazy, Suspense, useEffect } from 'react'+import { Suspense, useEffect } from 'react'import { Logo } from 'lib/brand'import { useResizeObserver } from 'lib/hooks/useResizeObserver'@@ -12,6 +12,7 @@ import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'import { Link } from 'lib/lemon-ui/Link'import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'import { humanFriendlyDuration } from 'lib/utils/durations'+import { lazyWithRetry } from 'lib/utils/retryImport'import { AUTO_REFRESH_INITIAL_INTERVAL_SECONDS } from 'scenes/dashboard/dashboardConstants'import { teamLogic } from 'scenes/teamLogic'@@ -20,12 +21,12 @@ import { ExportType, ExportedData } from '~/exporter/types'import { exporterViewLogic } from './exporterViewLogic'-const LazyDashboardScene = lazy(() => import('./scenes/ExporterDashboardScene'))-const LazyHeatmapScene = lazy(() => import('./scenes/ExporterHeatmapScene'))-const LazyInsightScene = lazy(() => import('./scenes/ExporterInsightScene'))-const LazyNotebookScene = lazy(() => import('./scenes/ExporterNotebookScene'))-const LazyRecordingScene = lazy(() => import('./scenes/ExporterRecordingScene'))-const LazyInterviewScene = lazy(() => import('./scenes/ExporterInterviewScene'))+const LazyDashboardScene = lazyWithRetry(() => import('./scenes/ExporterDashboardScene'))+const LazyHeatmapScene = lazyWithRetry(() => import('./scenes/ExporterHeatmapScene'))+const LazyInsightScene = lazyWithRetry(() => import('./scenes/ExporterInsightScene'))+const LazyNotebookScene = lazyWithRetry(() => import('./scenes/ExporterNotebookScene'))+const LazyRecordingScene = lazyWithRetry(() => import('./scenes/ExporterRecordingScene'))+const LazyInterviewScene = lazyWithRetry(() => import('./scenes/ExporterInterviewScene'))function ExportedSceneSkeleton(): JSX.Element {return (diff --git a/frontend/src/layout/GlobalModals.tsx b/frontend/src/layout/GlobalModals.tsxindex c15b524b1999..10d98244e67a 100644--- a/frontend/src/layout/GlobalModals.tsx+++ b/frontend/src/layout/GlobalModals.tsx@@ -1,5 +1,5 @@import { useActions, useValues } from 'kea'-import { Suspense, lazy } from 'react'+import { Suspense } from 'react'import { ItemSelectModal } from 'lib/components/FileSystem/ItemSelectModal/ItemSelectModal'import { LinkToModal } from 'lib/components/FileSystem/LinkTo/LinkTo'@@ -11,6 +11,7 @@ import { TimeSensitiveAuthenticationModal } from 'lib/components/TimeSensitiveAuimport { GlobalCustomUnitModal } from 'lib/components/UnitPicker/GlobalCustomUnitModal'import { UpgradeModal } from 'lib/components/UpgradeModal/UpgradeModal'import { useKeepMountedWhileOpen } from 'lib/hooks/useKeepMountedWhileOpen'+import { lazyWithRetry } from 'lib/utils/retryImport'import { TwoFactorSetupModal } from 'scenes/authentication/two-factor-setup/TwoFactorSetupModal'import { PaymentEntryModal } from 'scenes/billing/PaymentEntryModal'import { CreateOrganizationModal } from 'scenes/organization/CreateOrganizationModal'@@ -30,14 +31,14 @@ import { ConfigureHomeModal } from './scenes/ConfigureHomeModal'// The session player modal anchors the entire replay player graph; loading it only when a// recording is opened keeps that graph out of the chunk every logged-in page downloads.-const SessionPlayerModal = lazy(() =>+const SessionPlayerModal = lazyWithRetry(() =>import('scenes/session-recordings/player/modal/SessionPlayerModal').then((m) => ({default: m.SessionPlayerModal,})))// Same trick for the logs viewer, whose sparkline anchors chart.js.-const LogsViewerModal = lazy(() =>+const LogsViewerModal = lazyWithRetry(() =>import('products/logs/frontend/components/LogsViewer/LogsViewerModal').then((m) => ({default: m.LogsViewerModal,}))diff --git a/frontend/src/layout/navigation-3000/sidepanel/SidePanel.tsx b/frontend/src/layout/navigation-3000/sidepanel/SidePanel.tsxindex baefb6a59925..712bd058f1a8 100644--- a/frontend/src/layout/navigation-3000/sidepanel/SidePanel.tsx+++ b/frontend/src/layout/navigation-3000/sidepanel/SidePanel.tsx@@ -1,7 +1,7 @@import './SidePanel.scss'import { useActions, useValues } from 'kea'-import { lazy, Suspense, useEffect, useRef } from 'react'+import { Suspense, useEffect, useRef } from 'react'import { IconLock, IconLogomark, IconNotebook } from '@posthog/icons'@@ -9,8 +9,9 @@ import { Resizer } from 'lib/components/Resizer/Resizer'import { ResizerLogicProps, resizerLogic } from 'lib/components/Resizer/resizerLogic'import { Spinner } from 'lib/lemon-ui/Spinner'import { cn } from 'lib/utils/css-classes'+import { lazyWithRetry } from 'lib/utils/retryImport'-const NotebookPanel = lazy(() =>+const NotebookPanel = lazyWithRetry(() =>import('scenes/notebooks/NotebookPanel/NotebookPanel').then((m) => ({ default: m.NotebookPanel })))diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/max/SidePanelMax.tsx b/frontend/src/layout/navigation-3000/sidepanel/panels/max/SidePanelMax.tsxindex 212573393ae1..a5b0e0155550 100644--- a/frontend/src/layout/navigation-3000/sidepanel/panels/max/SidePanelMax.tsx+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/max/SidePanelMax.tsx@@ -1,8 +1,8 @@-import { lazy } from 'react'+import { lazyWithRetry } from 'lib/utils/retryImport'// Lazy so the side panel registry doesn't pull Max's thread graph (Query, message widgets)// into the shell chunk. SidePanel already wraps panel content in a Suspense boundary.-const MaxInstance = lazy(() => import('scenes/max/Max').then((m) => ({ default: m.MaxInstance })))+const MaxInstance = lazyWithRetry(() => import('scenes/max/Max').then((m) => ({ default: m.MaxInstance })))export function SidePanelMax(): JSX.Element | null {return <MaxInstance sidePanel />diff --git a/frontend/src/layout/panel-layout/ai-first/Nav.tsx b/frontend/src/layout/panel-layout/ai-first/Nav.tsxindex 8ed2d03186b8..570155d71b4a 100644--- a/frontend/src/layout/panel-layout/ai-first/Nav.tsx+++ b/frontend/src/layout/panel-layout/ai-first/Nav.tsx@@ -3,7 +3,7 @@ import { cva } from 'cva'import { useActions, useMountedLogic, useValues } from 'kea'import { router } from 'kea-router'import posthog from 'posthog-js'-import { lazy, Suspense, useEffect, useRef } from 'react'+import { Suspense, useEffect, useRef } from 'react'import { IconApps, IconChat, IconChevronRight, IconPlusSmall } from '@posthog/icons'@@ -21,6 +21,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from 'lib/ui/Dimport { Label } from 'lib/ui/Label/Label'import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'import { cn } from 'lib/utils/css-classes'+import { lazyWithRetry } from 'lib/utils/retryImport'import { newDashboardLogic } from 'scenes/dashboard/newDashboardLogic'import { urls } from 'scenes/urls'@@ -38,7 +39,7 @@ import { CreateMenu } from '../menus/CreateMenu'import { NavBarFooter } from '../NavBarFooter'import { PanelLayoutPanels } from './PanelLayoutPanels'import { NavTabBrowse } from './tabs/NavTabBrowse'-const NavTabChat = lazy(() => import('./tabs/NavTabChat').then((m) => ({ default: m.NavTabChat })))+const NavTabChat = lazyWithRetry(() => import('./tabs/NavTabChat').then((m) => ({ default: m.NavTabChat })))const navBarStyles = cva({base: 'flex flex-col max-h-screen min-h-screen bg-surface-tertiary z-[var(--z-layout-navbar)] relative border-r lg:border-r-transparent',diff --git a/frontend/src/layout/panel-layout/ai-first/PanelLayoutPanels.tsx b/frontend/src/layout/panel-layout/ai-first/PanelLayoutPanels.tsxindex 553e3c4f1f68..bba8a915dd3d 100644--- a/frontend/src/layout/panel-layout/ai-first/PanelLayoutPanels.tsx+++ b/frontend/src/layout/panel-layout/ai-first/PanelLayoutPanels.tsx@@ -1,15 +1,16 @@import { useActions, useValues } from 'kea'-import { lazy, Suspense, useCallback, useMemo } from 'react'+import { Suspense, useCallback, useMemo } from 'react'import { NotificationsPanel } from 'lib/components/NotificationsMenu/NotificationsPanel'import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'+import { lazyWithRetry } from 'lib/utils/retryImport'import { PanelLayoutNavIdentifier, panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'import { PROJECT_TREE_KEY, ProjectTree } from '../ProjectTree/ProjectTree'-const NavTabChat = lazy(() => import('./tabs/NavTabChat').then((m) => ({ default: m.NavTabChat })))+const NavTabChat = lazyWithRetry(() => import('./tabs/NavTabChat').then((m) => ({ default: m.NavTabChat })))// Renders the currently-active panel (Project tree, Notifications, Chat, etc.). Extracted so the// same active-panel JSX can be mounted at different positions in the DOM/stacking tree dependingdiff --git a/frontend/src/lib/components/ActivityLog/ActivityLog.tsx b/frontend/src/lib/components/ActivityLog/ActivityLog.tsxindex 5afaca74481d..91402b4c22fb 100644--- a/frontend/src/lib/components/ActivityLog/ActivityLog.tsx+++ b/frontend/src/lib/components/ActivityLog/ActivityLog.tsx@@ -4,7 +4,7 @@ import useSize from '@react-hook/size'import clsx from 'clsx'import { useValues } from 'kea'import { router } from 'kea-router'-import { lazy, Suspense, useEffect, useRef, useState } from 'react'+import { Suspense, useEffect, useRef, useState } from 'react'import { IconCollapse, IconExpand } from '@posthog/icons'import { LemonButton, LemonDivider, LemonTabs, Spinner } from '@posthog/lemon-ui'@@ -20,6 +20,7 @@ import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { userHasAccess } from 'lib/utils/accessControlUtils'import { copyToClipboard } from 'lib/utils/copyToClipboard'+import { lazyWithRetry } from 'lib/utils/retryImport'import { userLogic } from 'scenes/userLogic'import { ProductKey } from '~/queries/schema/schema-general'@@ -29,7 +30,7 @@ import { AccessDenied } from '../AccessDenied'import { PayGateMini } from '../PayGateMini/PayGateMini'import { ProductIntroduction } from '../ProductIntroduction/ProductIntroduction'-const MonacoDiffEditor = lazy(() => import('../MonacoDiffEditor'))+const MonacoDiffEditor = lazyWithRetry(() => import('../MonacoDiffEditor'))export type ActivityLogProps = ActivityLogLogicProps & {startingPage?: numberdiff --git a/frontend/src/lib/components/Cards/TextCard/TextCardModalBodyField.tsx b/frontend/src/lib/components/Cards/TextCard/TextCardModalBodyField.tsxindex ba1dcc7af0c1..3a43b4e0cfa4 100644--- a/frontend/src/lib/components/Cards/TextCard/TextCardModalBodyField.tsx+++ b/frontend/src/lib/components/Cards/TextCard/TextCardModalBodyField.tsx@@ -1,6 +1,7 @@-import { lazy, Suspense } from 'react'+import { Suspense } from 'react'import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'+import { lazyWithRetry } from 'lib/utils/retryImport'export interface TextCardModalBodyFieldProps {shouldUseLegacyMarkdownEditor: boolean@@ -8,13 +9,13 @@ export interface TextCardModalBodyFieldProps {onChange: (value: string) => void}-const LazyLegacyMarkdownEditor = lazy(() =>+const LazyLegacyMarkdownEditor = lazyWithRetry(() =>import('lib/lemon-ui/LemonTextArea/LemonTextAreaMarkdown').then((m) => ({default: m.LemonTextAreaMarkdown,})))-const LazyRichMarkdownEditor = lazy(() =>+const LazyRichMarkdownEditor = lazyWithRetry(() =>import('lib/components/Cards/TextCard/TextCardMarkdownEditor').then((m) => ({default: m.TextCardMarkdownEditor,}))diff --git a/frontend/src/lib/components/CyclotronJob/customInputRenderers.ts b/frontend/src/lib/components/CyclotronJob/customInputRenderers.tsindex f008e1af400b..37412a1b410a 100644--- a/frontend/src/lib/components/CyclotronJob/customInputRenderers.ts+++ b/frontend/src/lib/components/CyclotronJob/customInputRenderers.ts@@ -1,4 +1,6 @@-import { ComponentType, lazy } from 'react'+import { ComponentType } from 'react'++import { lazyWithRetry } from 'lib/utils/retryImport'import { CyclotronJobInputSchemaType, CyclotronJobInvocationGlobalsWithInputs } from '~/types'@@ -16,20 +18,20 @@ export const CUSTOM_INPUT_RENDERERS: Record<string,React.LazyExoticComponent<ComponentType<CustomInputRendererProps>>> = {- posthog_assignee: lazy(+ posthog_assignee: lazyWithRetry(() => import('products/conversations/frontend/components/Assignee/CyclotronJobInputAssignee')),- posthog_ticket_tags: lazy(+ posthog_ticket_tags: lazyWithRetry(() => import('products/conversations/frontend/components/TicketTags/CyclotronJobInputTicketTags')),- posthog_business_hours: lazy(+ posthog_business_hours: lazyWithRetry(() => import('products/conversations/frontend/components/SlaBusinessHours/CyclotronJobInputBusinessHours')),- customer_analytics_account_properties: lazy(+ customer_analytics_account_properties: lazyWithRetry(() =>import('products/customer_analytics/frontend/components/AccountPropertiesInput/CyclotronJobInputAccountProperties')),- customer_analytics_account_relationships: lazy(+ customer_analytics_account_relationships: lazyWithRetry(() =>import('products/customer_analytics/frontend/components/AccountRelationshipsInput/CyclotronJobInputAccountRelationships')),diff --git a/frontend/src/lib/components/HedgehogMode/HedgehogMode.tsx b/frontend/src/lib/components/HedgehogMode/HedgehogMode.tsxindex ed6f6ef1732b..eeac055e78ed 100644--- a/frontend/src/lib/components/HedgehogMode/HedgehogMode.tsx+++ b/frontend/src/lib/components/HedgehogMode/HedgehogMode.tsx@@ -1,7 +1,8 @@import { useActions, useValues } from 'kea'-import { Suspense, lazy } from 'react'+import { Suspense } from 'react'import { inStorybook } from 'lib/utils/dom'+import { lazyWithRetry } from 'lib/utils/retryImport'import { themeLogic } from '~/layout/navigation-3000/themeLogic'import { toolbarConfigLogic } from '~/toolbar/toolbarConfigLogic'@@ -12,7 +13,9 @@ import { HedgehogModeConfig } from './types'export const HedgeHogModeRenderer =typeof window !== 'undefined'- ? lazy(() => import('@posthog/hedgehog-mode').then((module) => ({ default: module.HedgehogModeRenderer })))+ ? lazyWithRetry(() =>+ import('@posthog/hedgehog-mode').then((module) => ({ default: module.HedgehogModeRenderer }))+ ): () => nullexport const getHedgehogModeAssetsUrl = (): string => {diff --git a/frontend/src/lib/components/HedgehogMode/HedgehogModeStatic.tsx b/frontend/src/lib/components/HedgehogMode/HedgehogModeStatic.tsxindex 860a28d1ad53..ee5db94b9956 100644--- a/frontend/src/lib/components/HedgehogMode/HedgehogModeStatic.tsx+++ b/frontend/src/lib/components/HedgehogMode/HedgehogModeStatic.tsx@@ -1,13 +1,17 @@import clsx from 'clsx'-import { Suspense, lazy, useMemo } from 'react'+import { Suspense, useMemo } from 'react'import type { HedgehogActorOptions } from '@posthog/hedgehog-mode'+import { lazyWithRetry } from 'lib/utils/retryImport'+import { HedgehogConfig, MinimalHedgehogConfig } from '~/types'import { getHedgehogModeAssetsUrl } from './HedgehogMode'-const StaticHedgehog = lazy(() => import('@posthog/hedgehog-mode').then((m) => ({ default: m.StaticHedgehog })))+const StaticHedgehog = lazyWithRetry(() =>+ import('@posthog/hedgehog-mode').then((m) => ({ default: m.StaticHedgehog }))+)export type HedgehogModeStaticProps = {size?: number | stringdiff --git a/frontend/src/lib/components/JSONViewer.tsx b/frontend/src/lib/components/JSONViewer.tsxindex 3b8d8cc8e2bd..fcbb20c08999 100644--- a/frontend/src/lib/components/JSONViewer.tsx+++ b/frontend/src/lib/components/JSONViewer.tsx@@ -2,13 +2,14 @@ import './JSONViewer.scss'import type { ReactJsonViewProps } from '@microlink/react-json-view'import { useValues } from 'kea'-import { Suspense, lazy } from 'react'+import { Suspense } from 'react'import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'+import { lazyWithRetry } from 'lib/utils/retryImport'import { themeLogic } from '~/layout/navigation-3000/themeLogic'-const ReactJson = lazy(() => import('@microlink/react-json-view'))+const ReactJson = lazyWithRetry(() => import('@microlink/react-json-view'))export enum JSONViewerTheme {DARK = 'railscasts',diff --git a/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.tsx b/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.tsxindex db69e979583b..b489b588d7f2 100644--- a/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.tsx+++ b/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.tsx@@ -12,7 +12,6 @@ import {MouseEvent as ReactMouseEvent,ReactNode,Suspense,- lazy,useCallback,useEffect,useId,@@ -27,9 +26,12 @@ import { LemonButton } from '@posthog/lemon-ui'import { Spinner } from 'lib/lemon-ui/Spinner'import { downloadFile } from 'lib/utils/dom'+import { lazyWithRetry } from 'lib/utils/retryImport'// Monaco is heavy, so the markdown source editor only loads when the source drawer opens.-const LazyCodeEditor = lazy(() => import('lib/monaco/CodeEditor').then((module) => ({ default: module.CodeEditor })))+const LazyCodeEditor = lazyWithRetry(() =>+ import('lib/monaco/CodeEditor').then((module) => ({ default: module.CodeEditor }))+)import { mergeNotebookMarkdownChanges } from './collaboration'import {diff --git a/frontend/src/lib/components/Shortcuts/utils/DebugCHQueries.tsx b/frontend/src/lib/components/Shortcuts/utils/DebugCHQueries.tsxindex 88748445a68a..6b3c3154ba50 100644--- a/frontend/src/lib/components/Shortcuts/utils/DebugCHQueries.tsx+++ b/frontend/src/lib/components/Shortcuts/utils/DebugCHQueries.tsx@@ -1,11 +1,14 @@-import { Suspense, lazy } from 'react'+import { Suspense } from 'react'import { LemonDialog } from 'lib/lemon-ui/LemonDialog'import { Spinner } from 'lib/lemon-ui/Spinner'+import { lazyWithRetry } from 'lib/utils/retryImport'import type { DebugCHQueriesProps } from './DebugCHQueriesImpl'-const LazyDebugCHQueries = lazy(() => import('./DebugCHQueriesImpl').then((m) => ({ default: m.DebugCHQueries })))+const LazyDebugCHQueries = lazyWithRetry(() =>+ import('./DebugCHQueriesImpl').then((m) => ({ default: m.DebugCHQueries }))+)/** Lazy facade so the debug panel's chart.js dependencies stay out of the eager menu/shortcut chunks. */export function DebugCHQueries(props: DebugCHQueriesProps): JSX.Element {diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/HogQLEditor.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/HogQLEditor.tsxindex 4b4f972367c0..cbbf388befe8 100644--- a/frontend/src/lib/components/TaxonomicFilter/menu/HogQLEditor.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/menu/HogQLEditor.tsx@@ -10,18 +10,19 @@* registry — Esc only fires `onBack` when no suggestion / find* widget is open so it still closes those first like users expect.*/-import { lazy, Suspense, useEffect, useRef, useState } from 'react'+import { Suspense, useEffect, useRef, useState } from 'react'import { Button, DialogFooter, Field, FieldContent, FieldDescription, FieldLabel, Skeleton } from '@posthog/quill'import { Link } from 'lib/lemon-ui/Link'+import { lazyWithRetry } from 'lib/utils/retryImport'import { useTaxonomicFilterContext } from '../headless/context'import { TaxonomicFilterGroupType } from '../types'import { MenuFilterHeader } from './Header'import { CommitFn, MenuFilterEntry } from './types'-const CodeEditorInline = lazy(() =>+const CodeEditorInline = lazyWithRetry(() =>import('lib/monaco/CodeEditorInline').then((m) => ({ default: m.CodeEditorInline })))diff --git a/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdownWithMermaid.tsx b/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdownWithMermaid.tsxindex 0ba10796897a..5276317fbaf7 100644--- a/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdownWithMermaid.tsx+++ b/frontend/src/lib/lemon-ui/LemonMarkdown/LemonMarkdownWithMermaid.tsx@@ -1,10 +1,11 @@-import { Suspense, lazy } from 'react'+import { Suspense } from 'react'import { Spinner } from 'lib/lemon-ui/Spinner'+import { lazyWithRetry } from 'lib/utils/retryImport'import { LemonMarkdown, LemonMarkdownProps } from './LemonMarkdown'-const LazyMermaidDiagram = lazy(() => import('./MermaidDiagram'))+const LazyMermaidDiagram = lazyWithRetry(() => import('./MermaidDiagram'))function renderMermaid(code: string): JSX.Element {return (diff --git a/frontend/src/lib/monaco/CodeEditor.tsx b/frontend/src/lib/monaco/CodeEditor.tsxindex 90e51cefc1f0..d0071afb36a9 100644--- a/frontend/src/lib/monaco/CodeEditor.tsx+++ b/frontend/src/lib/monaco/CodeEditor.tsx@@ -1,13 +1,14 @@-import { Suspense, lazy } from 'react'+import { Suspense } from 'react'import { Spinner } from 'lib/lemon-ui/Spinner'+import { lazyWithRetry } from 'lib/utils/retryImport'import type { CodeEditorProps } from './CodeEditorImpl'export type { CodeEditorProps } from './CodeEditorImpl'export { clearLogicReference, initModel } from './modelLogicReference'-const LazyCodeEditor = lazy(() => import('./CodeEditorImpl').then((m) => ({ default: m.CodeEditor })))+const LazyCodeEditor = lazyWithRetry(() => import('./CodeEditorImpl').then((m) => ({ default: m.CodeEditor })))/** Lazy facade so importing CodeEditor doesn't pull monaco (~4 MB) into the importer's chunk. */export function CodeEditor(props: CodeEditorProps): JSX.Element {diff --git a/frontend/src/lib/ui/DialogPrimitive/DialogPrimitive.tsx b/frontend/src/lib/ui/DialogPrimitive/DialogPrimitive.tsxindex b3006b8e48d9..d0917c56d0c1 100644--- a/frontend/src/lib/ui/DialogPrimitive/DialogPrimitive.tsx+++ b/frontend/src/lib/ui/DialogPrimitive/DialogPrimitive.tsx@@ -1,13 +1,16 @@import { Dialog } from '@base-ui/react/dialog'-import { Suspense, lazy } from 'react'+import { Suspense } from 'react'import { IconX } from '@posthog/icons'import { cn } from 'lib/utils/css-classes'+import { lazyWithRetry } from 'lib/utils/retryImport'import { WrappingLoadingSkeleton } from '../WrappingLoadingSkeleton/WrappingLoadingSkeleton'-const ButtonPrimitive = lazy(() => import('../Button/ButtonPrimitives').then((m) => ({ default: m.ButtonPrimitive })))+const ButtonPrimitive = lazyWithRetry(() =>+ import('../Button/ButtonPrimitives').then((m) => ({ default: m.ButtonPrimitive }))+)function DialogPrimitive({children,diff --git a/frontend/src/lib/utils/retryImport.ts b/frontend/src/lib/utils/retryImport.tsindex 5e9f619335c4..09474e1d3d33 100644--- a/frontend/src/lib/utils/retryImport.ts+++ b/frontend/src/lib/utils/retryImport.ts@@ -1,3 +1,5 @@+import { ComponentType, LazyExoticComponent, lazy } from 'react'+import { isChunkLoadError } from 'lib/utils/isChunkLoadError'/**@@ -24,3 +26,20 @@ export async function retryImport<T>(factory: () => T, retries = 2, baseDelayMsreturn retryImport(factory, retries - 1, baseDelayMs * 2)}}++/**+ * Drop-in replacement for `React.lazy` that retries a transient chunk-load failure before giving up.+ *+ * Lazily-loaded chunks are content-hashed per deploy, so a tab opened before a deploy can fail to+ * fetch a now-deleted chunk ("Failed to fetch dynamically imported module"). `retryImport` re-attempts+ * the import a few times (preserving page state) before the error propagates to `ChunkLoadErrorBoundary`+ * for a one-time reload. This is the same wrapping the scene loader (`sceneLogic`) and the root `App`+ * lazy import already use; this helper just makes it the easy default for any lazily-loaded component.+ *+ * Prefer this over `lazy(() => import(...))`.+ */+export function lazyWithRetry<T extends ComponentType<any>>(+ factory: () => Promise<{ default: T }>+): LazyExoticComponent<T> {+ return lazy(() => retryImport(factory))+}diff --git a/frontend/src/queries/Query/Query.tsx b/frontend/src/queries/Query/Query.tsxindex 8b1013c424d3..c4e9c175e782 100644--- a/frontend/src/queries/Query/Query.tsx+++ b/frontend/src/queries/Query/Query.tsx@@ -1,8 +1,9 @@import { BuiltLogic, LogicWrapper } from 'kea'-import { Suspense, lazy, useEffect, useState } from 'react'+import { Suspense, useEffect, useState } from 'react'import { LemonDivider } from 'lib/lemon-ui/LemonDivider'import { Spinner } from 'lib/lemon-ui/Spinner'+import { lazyWithRetry } from 'lib/utils/retryImport'import { HogDebug } from 'scenes/debug/HogDebug'import { MarketingAnalyticsOverview } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/MarketingAnalyticsOverview/MarketingAnalyticsOverview'@@ -55,8 +56,10 @@ import {isWebVitalsQuery,} from '../utils'-const WebVitals = lazy(() => import('~/queries/nodes/WebVitals/WebVitals').then((m) => ({ default: m.WebVitals })))-const WebVitalsPathBreakdown = lazy(() =>+const WebVitals = lazyWithRetry(() =>+ import('~/queries/nodes/WebVitals/WebVitals').then((m) => ({ default: m.WebVitals }))+)+const WebVitalsPathBreakdown = lazyWithRetry(() =>import('../nodes/WebVitals/WebVitalsPathBreakdown').then((m) => ({ default: m.WebVitalsPathBreakdown })))diff --git a/frontend/src/scenes/App.tsx b/frontend/src/scenes/App.tsxindex 2c1c6b5c7c30..05a45b501420 100644--- a/frontend/src/scenes/App.tsx+++ b/frontend/src/scenes/App.tsx@@ -120,7 +120,7 @@ export function App(): JSX.Element | null {// root init and triggers a circular-import TDZ. Its urlToAction fires on the current URL on mount.useEffect(() => {let unmount: (() => void) | undefined- void import('lib/components/Support/supportRouterLogic').then(({ supportRouterLogic }) => {+ void retryImport(() => import('lib/components/Support/supportRouterLogic')).then(({ supportRouterLogic }) => {unmount = supportRouterLogic.mount()})return () => unmount?.()diff --git a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsxindex 69b3d1637641..ad115442f168 100644--- a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx+++ b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx@@ -19,7 +19,7 @@ import { router, urlToAction } from 'kea-router'import { subscriptions } from 'kea-subscriptions'import { type IRange, Uri, editor } from 'monaco-editor'import posthog from 'posthog-js'-import { Suspense, lazy } from 'react'+import { Suspense } from 'react'import { LemonCheckbox, LemonDialog, LemonInput, LemonSelect, Spinner, lemonToast, Tooltip } from '@posthog/lemon-ui'@@ -33,6 +33,7 @@ import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'import { clearLogicReference, initModel } from 'lib/monaco/CodeEditor'import { codeEditorLogic } from 'lib/monaco/codeEditorLogic'import { objectsEqual } from 'lib/utils/objects'+import { lazyWithRetry } from 'lib/utils/retryImport'import { slugify } from 'lib/utils/strings'import { DashboardLoadAction, dashboardLogic } from 'scenes/dashboard/dashboardLogic'import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'@@ -427,7 +428,9 @@ function applyUndoableModelEdit(monaco: Monaco | null | undefined, uri: Uri | unmodel.pushStackElement()}-const LazyQuery = lazy(() => import('~/queries/Query/Query').then((m) => ({ default: m.Query<DataVisualizationNode> })))+const LazyQuery = lazyWithRetry(() =>+ import('~/queries/Query/Query').then((m) => ({ default: m.Query<DataVisualizationNode> }))+)export const sqlEditorLogic = kea<sqlEditorLogicType>([path(['data-warehouse', 'editor', 'sqlEditorLogic']),diff --git a/frontend/src/scenes/hog-functions/misc/activityDescriptions.tsx b/frontend/src/scenes/hog-functions/misc/activityDescriptions.tsxindex f8d43de58861..fa96066fb1a1 100644--- a/frontend/src/scenes/hog-functions/misc/activityDescriptions.tsx+++ b/frontend/src/scenes/hog-functions/misc/activityDescriptions.tsx@@ -1,4 +1,4 @@-import { Suspense, lazy } from 'react'+import { Suspense } from 'react'import {ActivityLogItem,@@ -10,6 +10,7 @@ import { LemonDropdown } from 'lib/lemon-ui/LemonDropdown'import { Link } from 'lib/lemon-ui/Link'import { Spinner } from 'lib/lemon-ui/Spinner'import { isObject } from 'lib/utils/guards'+import { lazyWithRetry } from 'lib/utils/retryImport'import { urls } from 'scenes/urls'import { HogFunctionTypeType } from '~/types'@@ -22,7 +23,7 @@ const nameOrLinkToHogFunction = (id?: string | null, name?: string | null): strireturn id ? <Link to={urls.hogFunction(id)}>{displayName}</Link> : displayName}-const LazyDiff = lazy(() => import('./Diff').then((m) => ({ default: m.Diff })))+const LazyDiff = lazyWithRetry(() => import('./Diff').then((m) => ({ default: m.Diff })))/** Lazy so the activity describer registry (imported app-wide) doesn't pull monaco into its chunk. */export function Diff(props: DiffProps): JSX.Element {diff --git a/frontend/src/scenes/max/messages/adapters/registerMaxToolRenderers.tsx b/frontend/src/scenes/max/messages/adapters/registerMaxToolRenderers.tsxindex dc022f64f2f2..8281a18c7c2a 100644--- a/frontend/src/scenes/max/messages/adapters/registerMaxToolRenderers.tsx+++ b/frontend/src/scenes/max/messages/adapters/registerMaxToolRenderers.tsx@@ -1,4 +1,4 @@-import { type ComponentType, lazy } from 'react'+import { type ComponentType } from 'react'import {IconDashboard,@@ -16,6 +16,8 @@ import {IconWarning,} from '@posthog/icons'+import { lazyWithRetry } from 'lib/utils/retryImport'+import {registerToolRenderers,type ToolRegistryEntry,@@ -29,19 +31,23 @@ import {// they're resolved when a sandbox conversation renders the matching tool call. Surfaces that never load// Max (tasks, signals inbox) simply fall through to the generic MCP card for these keys.//-// Renderers are code-split: each lazy() pulls its chunk on first use, not at registration time.-const InsightRenderer = lazy(() => import('./CreateInsightWidget').then((m) => ({ default: m.CreateInsightWidget })))-const DashboardRenderer = lazy(() =>+// Renderers are code-split: each lazyWithRetry() pulls its chunk on first use, not at registration time.+const InsightRenderer = lazyWithRetry(() =>+ import('./CreateInsightWidget').then((m) => ({ default: m.CreateInsightWidget }))+)+const DashboardRenderer = lazyWithRetry(() =>import('./UpsertDashboardWidget').then((m) => ({ default: m.UpsertDashboardWidget })))-const SessionRecordingsRenderer = lazy(() =>+const SessionRecordingsRenderer = lazyWithRetry(() =>import('./SearchSessionRecordingsWidget').then((m) => ({ default: m.SearchSessionRecordingsWidget })))-const ErrorTrackingRenderer = lazy(() =>+const ErrorTrackingRenderer = lazyWithRetry(() =>import('./ErrorTrackingWidget').then((m) => ({ default: m.ErrorTrackingWidget })))-const NotebookRenderer = lazy(() => import('./CreateNotebookWidget').then((m) => ({ default: m.CreateNotebookWidget })))-const QueryRenderer = lazy(() => import('./QueryWidget').then((m) => ({ default: m.QueryWidget })))+const NotebookRenderer = lazyWithRetry(() =>+ import('./CreateNotebookWidget').then((m) => ({ default: m.CreateNotebookWidget }))+)+const QueryRenderer = lazyWithRetry(() => import('./QueryWidget').then((m) => ({ default: m.QueryWidget })))// The single-exec inner tool names exist in two conventions — hyphenated (the MCP yaml definitions) and// snake_case (legacy Max tools) — so we register both aliases where both are real tool names. Each calldiff --git a/frontend/src/scenes/settings/user/HedgehogModeSettings.tsx b/frontend/src/scenes/settings/user/HedgehogModeSettings.tsxindex eb7d84fb6f6b..a194161809d2 100644--- a/frontend/src/scenes/settings/user/HedgehogModeSettings.tsx+++ b/frontend/src/scenes/settings/user/HedgehogModeSettings.tsx@@ -1,19 +1,22 @@import { useActions, useValues } from 'kea'-import { Suspense, lazy, useEffect, useState } from 'react'+import { Suspense, useEffect, useState } from 'react'import { LemonSkeleton, LemonSwitch } from '@posthog/lemon-ui'import { getHedgehogModeAssetsUrl } from 'lib/components/HedgehogMode/HedgehogMode'import { hedgehogModeLogic } from 'lib/components/HedgehogMode/hedgehogModeLogic'+import { lazyWithRetry } from 'lib/utils/retryImport'const LazyHedgehogCustomization =typeof window !== 'undefined'- ? lazy(() => import('@posthog/hedgehog-mode').then((module) => ({ default: module.HedgehogCustomization })))+ ? lazyWithRetry(() =>+ import('@posthog/hedgehog-mode').then((module) => ({ default: module.HedgehogCustomization }))+ ): () => nullconst LazyHedgehogModeRendererContent =typeof window !== 'undefined'- ? lazy(() =>+ ? lazyWithRetry(() =>import('@posthog/hedgehog-mode').then((module) => ({ default: module.HedgehogModeRendererContent }))): () => nulldiff --git a/frontend/src/scenes/trends/Trends.tsx b/frontend/src/scenes/trends/Trends.tsxindex 89a1aabbdbfe..d4a965ec8d17 100644--- a/frontend/src/scenes/trends/Trends.tsx+++ b/frontend/src/scenes/trends/Trends.tsx@@ -1,9 +1,10 @@import { useActions, useValues } from 'kea'-import { Suspense, lazy } from 'react'+import { Suspense } from 'react'import { LemonButton } from '@posthog/lemon-ui'import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'+import { lazyWithRetry } from 'lib/utils/retryImport'import { insightLogic } from 'scenes/insights/insightLogic'import { BoldNumber } from 'scenes/insights/views/BoldNumber'import { InsightsTable } from 'scenes/insights/views/InsightsTable/InsightsTable'@@ -15,49 +16,51 @@ import { ChartDisplayType, InsightType } from '~/types'import { trendsDataLogic } from './trendsDataLogic'// Lazy-loaded viz types that are rarely used on dashboards-const WorldMap = lazy(() => import('scenes/insights/views/WorldMap').then((m) => ({ default: m.WorldMap })))-const RegionMap = lazy(() => import('scenes/insights/views/RegionMap').then((m) => ({ default: m.RegionMap })))-const TrendsCalendarHeatMap = lazy(() =>+const WorldMap = lazyWithRetry(() => import('scenes/insights/views/WorldMap').then((m) => ({ default: m.WorldMap })))+const RegionMap = lazyWithRetry(() => import('scenes/insights/views/RegionMap').then((m) => ({ default: m.RegionMap })))+const TrendsCalendarHeatMap = lazyWithRetry(() =>import('scenes/insights/views/CalendarHeatMap').then((m) => ({ default: m.TrendsCalendarHeatMap })))-const BoxPlotChart = lazy(() => import('scenes/insights/views/BoxPlot').then((m) => ({ default: m.BoxPlotChart })))+const BoxPlotChart = lazyWithRetry(() =>+ import('scenes/insights/views/BoxPlot').then((m) => ({ default: m.BoxPlotChart }))+)// Lazy-loaded — keep the quill/d3 slope chart out of the eager Trends/Dashboard bundle-const TrendsSlopeChart = lazy(() =>+const TrendsSlopeChart = lazyWithRetry(() =>import('products/product_analytics/frontend/insights/trends/TrendsSlopeChart/TrendsSlopeChart').then((m) => ({default: m.TrendsSlopeChart,})))// Lazy-loaded — keep full d3 out of the eager Trends/Dashboard bundle-const TrendsLineChart = lazy(() =>+const TrendsLineChart = lazyWithRetry(() =>import('products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart').then((m) => ({default: m.TrendsLineChart,})))-const TrendsBarChart = lazy(() =>+const TrendsBarChart = lazyWithRetry(() =>import('products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart').then((m) => ({default: m.TrendsBarChart,})))-const StickinessLineChart = lazy(() =>+const StickinessLineChart = lazyWithRetry(() =>import('products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart').then((m) => ({default: m.StickinessLineChart,})))-const StickinessBarChart = lazy(() =>+const StickinessBarChart = lazyWithRetry(() =>import('products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart').then((m) => ({default: m.StickinessBarChart,})))-const TrendsPieChart = lazy(() =>+const TrendsPieChart = lazyWithRetry(() =>import('products/product_analytics/frontend/insights/trends/TrendsPieChart/TrendsPieChart').then((m) => ({default: m.TrendsPieChart,})))-const TrendsLifecycleChart = lazy(() =>+const TrendsLifecycleChart = lazyWithRetry(() =>import('products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart').then((m) => ({default: m.TrendsLifecycleChart,diff --git a/frontend/src/taxonomy/transformations.tsx b/frontend/src/taxonomy/transformations.tsxindex 5671668905c2..bdb74c34a328 100644--- a/frontend/src/taxonomy/transformations.tsx+++ b/frontend/src/taxonomy/transformations.tsx@@ -1,8 +1,10 @@-import { lazy, Suspense } from 'react'+import { Suspense } from 'react'++import { lazyWithRetry } from 'lib/utils/retryImport'import { CoreFilterDefinition } from '~/types'-const LazyLink = lazy(() => import('lib/lemon-ui/Link').then((m) => ({ default: m.Link })))+const LazyLink = lazyWithRetry(() => import('lib/lemon-ui/Link').then((m) => ({ default: m.Link })))type RawCoreFilterDefinition = {label: stringdiff --git a/products/ai_observability/frontend/AIObservabilitySessionScene.tsx b/products/ai_observability/frontend/AIObservabilitySessionScene.tsxindex ecf196860c91..be37444c3a8e 100644--- a/products/ai_observability/frontend/AIObservabilitySessionScene.tsx+++ b/products/ai_observability/frontend/AIObservabilitySessionScene.tsx@@ -1,6 +1,6 @@import { BindLogic, useActions, useValues } from 'kea'import { combineUrl, router } from 'kea-router'-import { type Ref, Suspense, lazy, useEffect, useRef } from 'react'+import { type Ref, Suspense, useEffect, useRef } from 'react'import { IconWarning, IconWrench } from '@posthog/icons'import { LemonButton, LemonDrawer, LemonTag, Spinner, SpinnerOverlay, Tooltip } from '@posthog/lemon-ui'@@ -12,6 +12,7 @@ import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'import { Link } from 'lib/lemon-ui/Link'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'+import { lazyWithRetry } from 'lib/utils/retryImport'import { InsightEmptyState, InsightErrorState } from 'scenes/insights/EmptyStates'import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'import { SceneExport } from 'scenes/sceneTypes'@@ -38,7 +39,7 @@ import { llmSessionTitleLazyLoaderLogic } from './llmSessionTitleLazyLoaderLogicimport { sessionPlaybackLogic } from './sessionPlaybackLogic'import { formatLLMCost, getTraceTimestamp, sanitizeTraceUrlSearchParams } from './utils'-const LLMASessionFeedbackDisplay = lazy(() =>+const LLMASessionFeedbackDisplay = lazyWithRetry(() =>import('./LLMASessionFeedbackDisplay').then((m) => ({ default: m.LLMASessionFeedbackDisplay })))diff --git a/products/ai_observability/frontend/prompts/promptSceneComponents.tsx b/products/ai_observability/frontend/prompts/promptSceneComponents.tsxindex e6704ae01c72..3369df13a03d 100644--- a/products/ai_observability/frontend/prompts/promptSceneComponents.tsx+++ b/products/ai_observability/frontend/prompts/promptSceneComponents.tsx@@ -1,6 +1,6 @@import { useActions, useValues } from 'kea'import { combineUrl } from 'kea-router'-import { lazy, Suspense, useRef } from 'react'+import { Suspense, useRef } from 'react'import { IconColumns, IconMarkdown, IconMarkdownFilled } from '@posthog/icons'import {@@ -23,6 +23,7 @@ import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'import { LemonTable, LemonTableColumns } from 'lib/lemon-ui/LemonTable'import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'+import { lazyWithRetry } from 'lib/utils/retryImport'import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'@@ -39,7 +40,7 @@ import { PromptAnalyticsScope, isPrompt, llmPromptLogic } from './llmPromptLogicimport { promptExperimentsLogic } from './promptExperimentsLogic'import { PROMPT_NAME_MAX_LENGTH } from './utils'-const MonacoDiffEditor = lazy(() => import('lib/components/MonacoDiffEditor'))+const MonacoDiffEditor = lazyWithRetry(() => import('lib/components/MonacoDiffEditor'))function PromptOutline({promptText,diff --git a/products/dashboards/frontend/widgets/experiments/LazyNotebookCompactTable.tsx b/products/dashboards/frontend/widgets/experiments/LazyNotebookCompactTable.tsxindex 4a1411d2efed..c7479c4e3f4b 100644--- a/products/dashboards/frontend/widgets/experiments/LazyNotebookCompactTable.tsx+++ b/products/dashboards/frontend/widgets/experiments/LazyNotebookCompactTable.tsx@@ -1,7 +1,9 @@-import { lazy, Suspense } from 'react'+import { Suspense } from 'react'import { LemonSkeleton } from '@posthog/lemon-ui'+import { lazyWithRetry } from 'lib/utils/retryImport'+import type { ExperimentMetric, NewExperimentQueryResponse } from '~/queries/schema/schema-general'type NotebookCompactTableProps = {@@ -12,7 +14,7 @@ type NotebookCompactTableProps = {// Lazy facade: the real table reuses the experiments scene (experimentLogic, featureFlagLogic, luxon,// cron-parser) — ~1.5 MiB. A static import would pull all of that into the always-loaded dashboard// graph; behind a dynamic import it loads only when a results widget actually renders.-const LazyTable = lazy(() =>+const LazyTable = lazyWithRetry(() =>import('scenes/experiments/notebook/NotebookCompactTable').then((module) => ({default: module.NotebookCompactTable,}))diff --git a/products/dashboards/frontend/widgets/registry.tsx b/products/dashboards/frontend/widgets/registry.tsxindex 1a4ca7c601e8..e77973b0d34a 100644--- a/products/dashboards/frontend/widgets/registry.tsx+++ b/products/dashboards/frontend/widgets/registry.tsx@@ -1,5 +1,7 @@import posthog from 'posthog-js'-import { type ComponentType, type LazyExoticComponent, lazy } from 'react'+import { type ComponentType, type LazyExoticComponent } from 'react'++import { lazyWithRetry } from 'lib/utils/retryImport'import type { DashboardWidgetTopHeadingProps } from '../components/WidgetCard/WidgetCardHeader'import type { DashboardWidgetProductAccess } from '../types'@@ -30,78 +32,78 @@ import { parseSurveyResultsWidgetConfigApiError } from './surveys/surveysWidgetC// factories below, so a logged-in page no longer eagerly downloads every widget's renderer, edit// modal, and tile-filter bar. Each widget's subtree loads only when its tile actually renders.// Rendered through <Suspense> boundaries in DashboardWidgetItem and WidgetCardHeader.-const ActivityEventsWidget = lazy(() =>+const ActivityEventsWidget = lazyWithRetry(() =>import('./activity/ActivityEventsWidget').then((m) => ({ default: m.ActivityEventsWidget })))-const ActivityEventsWidgetTileFilters = lazy(() =>+const ActivityEventsWidgetTileFilters = lazyWithRetry(() =>import('./activity/ActivityEventsWidgetTileFilters').then((m) => ({ default: m.ActivityEventsWidgetTileFilters })))-const EditActivityEventsWidgetModal = lazy(() =>+const EditActivityEventsWidgetModal = lazyWithRetry(() =>import('./activity/EditActivityEventsWidgetModal').then((m) => ({ default: m.EditActivityEventsWidgetModal })))-const ErrorTrackingWidget = lazy(() =>+const ErrorTrackingWidget = lazyWithRetry(() =>import('./error_tracking/ErrorTrackingWidget').then((m) => ({ default: m.ErrorTrackingWidget })))-const ErrorTrackingWidgetTileFilters = lazy(() =>+const ErrorTrackingWidgetTileFilters = lazyWithRetry(() =>import('./error_tracking/ErrorTrackingWidgetTileFilters').then((m) => ({default: m.ErrorTrackingWidgetTileFilters,})))-const EditErrorTrackingWidgetModal = lazy(() =>+const EditErrorTrackingWidgetModal = lazyWithRetry(() =>import('./error_tracking/EditErrorTrackingWidgetModal').then((m) => ({ default: m.EditErrorTrackingWidgetModal })))-const ExperimentResultsWidget = lazy(() =>+const ExperimentResultsWidget = lazyWithRetry(() =>import('./experiments/ExperimentResultsWidget').then((m) => ({ default: m.ExperimentResultsWidget })))-const ExperimentResultsWidgetTileFilters = lazy(() =>+const ExperimentResultsWidgetTileFilters = lazyWithRetry(() =>import('./experiments/ExperimentResultsWidgetTileFilters').then((m) => ({default: m.ExperimentResultsWidgetTileFilters,})))-const EditExperimentResultsWidgetModal = lazy(() =>+const EditExperimentResultsWidgetModal = lazyWithRetry(() =>import('./experiments/EditExperimentResultsWidgetModal').then((m) => ({default: m.EditExperimentResultsWidgetModal,})))-const ExperimentsListWidget = lazy(() =>+const ExperimentsListWidget = lazyWithRetry(() =>import('./experiments/ExperimentsListWidget').then((m) => ({ default: m.ExperimentsListWidget })))-const ExperimentsListWidgetTileFilters = lazy(() =>+const ExperimentsListWidgetTileFilters = lazyWithRetry(() =>import('./experiments/ExperimentsListWidgetTileFilters').then((m) => ({default: m.ExperimentsListWidgetTileFilters,})))-const EditExperimentsListWidgetModal = lazy(() =>+const EditExperimentsListWidgetModal = lazyWithRetry(() =>import('./experiments/EditExperimentsListWidgetModal').then((m) => ({ default: m.EditExperimentsListWidgetModal })))-const LogsWidget = lazy(() => import('./logs/LogsWidget').then((m) => ({ default: m.LogsWidget })))-const LogsWidgetTileFilters = lazy(() =>+const LogsWidget = lazyWithRetry(() => import('./logs/LogsWidget').then((m) => ({ default: m.LogsWidget })))+const LogsWidgetTileFilters = lazyWithRetry(() =>import('./logs/LogsWidgetTileFilters').then((m) => ({ default: m.LogsWidgetTileFilters })))-const EditLogsWidgetModal = lazy(() =>+const EditLogsWidgetModal = lazyWithRetry(() =>import('./logs/EditLogsWidgetModal').then((m) => ({ default: m.EditLogsWidgetModal })))-const SessionReplayWidget = lazy(() =>+const SessionReplayWidget = lazyWithRetry(() =>import('./session_replay/SessionReplayWidget').then((m) => ({ default: m.SessionReplayWidget })))-const SessionReplayWidgetTopHeading = lazy(() =>+const SessionReplayWidgetTopHeading = lazyWithRetry(() =>import('./session_replay/SessionReplayWidget').then((m) => ({ default: m.SessionReplayWidgetTopHeading })))-const SessionReplayWidgetTileFilters = lazy(() =>+const SessionReplayWidgetTileFilters = lazyWithRetry(() =>import('./session_replay/SessionReplayWidgetTileFilters').then((m) => ({default: m.SessionReplayWidgetTileFilters,})))-const EditSessionReplayWidgetModal = lazy(() =>+const EditSessionReplayWidgetModal = lazyWithRetry(() =>import('./session_replay/EditSessionReplayWidgetModal').then((m) => ({ default: m.EditSessionReplayWidgetModal })))-const SurveyResultsWidget = lazy(() =>+const SurveyResultsWidget = lazyWithRetry(() =>import('./surveys/SurveyResultsWidget').then((m) => ({ default: m.SurveyResultsWidget })))-const SurveyResultsWidgetTileFilters = lazy(() =>+const SurveyResultsWidgetTileFilters = lazyWithRetry(() =>import('./surveys/SurveyResultsWidgetTileFilters').then((m) => ({ default: m.SurveyResultsWidgetTileFilters })))-const EditSurveyResultsWidgetModal = lazy(() =>+const EditSurveyResultsWidgetModal = lazyWithRetry(() =>import('./surveys/EditSurveyResultsWidgetModal').then((m) => ({ default: m.EditSurveyResultsWidgetModal })))diff --git a/products/posthog_ai/frontend/components/EmbeddedRunner.tsx b/products/posthog_ai/frontend/components/EmbeddedRunner.tsxindex 66129a367e68..1ed17da83fd1 100644--- a/products/posthog_ai/frontend/components/EmbeddedRunner.tsx+++ b/products/posthog_ai/frontend/components/EmbeddedRunner.tsx@@ -1,6 +1,7 @@-import { lazy, Suspense } from 'react'+import { Suspense } from 'react'import { Spinner } from 'lib/lemon-ui/Spinner'+import { lazyWithRetry } from 'lib/utils/retryImport'import type { TaskTrackerProps } from '../scenes/TaskTracker/TaskTracker'@@ -9,7 +10,7 @@ export type { TaskTrackerProps } from '../scenes/TaskTracker/TaskTracker'// The TaskTracker scene (master/detail list + composer + run detail) is the heavy runner UI. It's loaded on// demand so a consumer that only links to it — e.g. the Max scene rendering it behind the sandbox view// toggle — doesn't statically pull it into its own chunk. Only `react` + a lightweight spinner load eagerly.-const Lazy = lazy(() => import('../scenes/TaskTracker/TaskTracker').then((m) => ({ default: m.TaskTracker })))+const Lazy = lazyWithRetry(() => import('../scenes/TaskTracker/TaskTracker').then((m) => ({ default: m.TaskTracker })))/*** Embeddable, code-split TaskTracker runner. Renders the standalone `/tasks` product (tasks list + composerdiff --git a/products/posthog_ai/frontend/components/ReadonlyRunSurface.tsx b/products/posthog_ai/frontend/components/ReadonlyRunSurface.tsxindex 39adf5ffb5bb..54f6073bb283 100644--- a/products/posthog_ai/frontend/components/ReadonlyRunSurface.tsx+++ b/products/posthog_ai/frontend/components/ReadonlyRunSurface.tsx@@ -1,4 +1,6 @@-import { lazy, Suspense } from 'react'+import { Suspense } from 'react'++import { lazyWithRetry } from 'lib/utils/retryImport'import type { ReadonlyRunSurfaceProps } from './ReadonlyRunSurfaceImpl'import { RunLogSkeleton } from './RunLogSkeleton'@@ -9,7 +11,7 @@ export type { ReadonlyRunSurfaceProps } from './ReadonlyRunSurfaceImpl'// demand; the RunLogSkeleton fallback matches the loaded thread, so the surface keeps its shape across// chunk-load → bootstrap → first frame. Only `react` + the lightweight skeleton are imported statically — the// impl is reached solely via dynamic `import()` (the type import below is erased), so the chunk genuinely splits.-const Lazy = lazy(() => import('./ReadonlyRunSurfaceImpl'))+const Lazy = lazyWithRetry(() => import('./ReadonlyRunSurfaceImpl'))/*** Prepackaged read-only run surface, code-split behind a `RunLogSkeleton` fallback. This is the commondiff --git a/products/posthog_ai/frontend/components/SidePanelRunner.tsx b/products/posthog_ai/frontend/components/SidePanelRunner.tsxindex 22ca2db3fdf2..70b1188d4c88 100644--- a/products/posthog_ai/frontend/components/SidePanelRunner.tsx+++ b/products/posthog_ai/frontend/components/SidePanelRunner.tsx@@ -1,6 +1,7 @@-import { lazy, Suspense } from 'react'+import { Suspense } from 'react'import { Spinner } from 'lib/lemon-ui/Spinner'+import { lazyWithRetry } from 'lib/utils/retryImport'import type { SidePanelRunnerImplProps } from '../scenes/TaskTracker/components/SidePanelRunnerImpl'@@ -9,7 +10,7 @@ export type SidePanelRunnerProps = SidePanelRunnerImplProps// The compact side-panel task-run surface (composer -> pending thread -> live run, no list/detail chrome) is// loaded on demand so a consumer that only links to it — e.g. Max's side panel — doesn't statically pull the// TaskTracker scene's components into its own chunk. Only `react` + a lightweight spinner load eagerly.-const Lazy = lazy(() =>+const Lazy = lazyWithRetry(() =>import('../scenes/TaskTracker/components/SidePanelRunnerImpl').then((m) => ({ default: m.SidePanelRunnerImpl })))diff --git a/products/posthog_ai/frontend/components/tool/builtinToolRenderers.tsx b/products/posthog_ai/frontend/components/tool/builtinToolRenderers.tsxindex 5291ff5a7376..f735e2bf9ba7 100644--- a/products/posthog_ai/frontend/components/tool/builtinToolRenderers.tsx+++ b/products/posthog_ai/frontend/components/tool/builtinToolRenderers.tsx@@ -1,9 +1,10 @@-import { Suspense, lazy, memo } from 'react'+import { Suspense, memo } from 'react'import { IconDocument, IconGlobe, IconMagicWand, IconSearch, IconTerminal, IconWrench } from '@posthog/icons'// IconRobot is not exported from @posthog/icons — it lives only in the legacy lib icon set.import { IconRobot } from 'lib/lemon-ui/icons'+import { lazyWithRetry } from 'lib/utils/retryImport'import { EditorSkeleton } from './EditorSkeleton'import { FilePath } from './FilePath'@@ -29,7 +30,7 @@ import { ToolBody, ToolBodySection, ToolOutput } from './ToolOutput'import type { ToolRendererProps } from './toolRegistry'// Monaco-backed read-only file view, lazy so monaco stays out of the always-loaded built-in chunk.-const ReadFileContent = lazy(() => import('./ReadFileContent').then((m) => ({ default: m.ReadFileContent })))+const ReadFileContent = lazyWithRetry(() => import('./ReadFileContent').then((m) => ({ default: m.ReadFileContent })))function asString(value: unknown): string {return typeof value === 'string' ? value : ''diff --git a/products/posthog_ai/frontend/components/tool/toolRegistry.tsx b/products/posthog_ai/frontend/components/tool/toolRegistry.tsxindex c4a20c2eb124..cca1fd30b82e 100644--- a/products/posthog_ai/frontend/components/tool/toolRegistry.tsx+++ b/products/posthog_ai/frontend/components/tool/toolRegistry.tsx@@ -1,4 +1,4 @@-import { type ComponentType, type LazyExoticComponent, lazy } from 'react'+import { type ComponentType, type LazyExoticComponent } from 'react'import {IconAI,@@ -18,6 +18,7 @@ import {// IconRobot is not exported from @posthog/icons — it lives only in the legacy lib icon set.import { IconRobot } from 'lib/lemon-ui/icons'+import { lazyWithRetry } from 'lib/utils/retryImport'import type { ToolCallMessage } from 'products/posthog_ai/frontend/types/toolTypes'@@ -75,12 +76,16 @@ class MapBackedRegistry implements ToolRegistry {// sandbox conversation pulls a renderer's chunk on first use, not at thread mount. The built-in tools// and the generic MCP card share one chunk (`builtinToolRenderers`); each heavy data-tool adapter and// the Monaco-backed diff renderer stay in their own chunks.-const BuiltinToolRenderer = lazy(() =>+const BuiltinToolRenderer = lazyWithRetry(() =>import('./builtinToolRenderers').then((m) => ({ default: m.BuiltinToolRenderer })))-const EditToolRenderer = lazy(() => import('./EditDiffRenderer').then((m) => ({ default: m.EditDiffRenderer })))-const QuestionRenderer = lazy(() => import('../QuestionRenderer').then((m) => ({ default: m.QuestionRenderer })))-const PostHogCodeToolRenderer = lazy(() =>+const EditToolRenderer = lazyWithRetry(() =>+ import('./EditDiffRenderer').then((m) => ({ default: m.EditDiffRenderer }))+)+const QuestionRenderer = lazyWithRetry(() =>+ import('../QuestionRenderer').then((m) => ({ default: m.QuestionRenderer }))+)+const PostHogCodeToolRenderer = lazyWithRetry(() =>import('./posthogCodeToolRenderers').then((m) => ({ default: m.PostHogCodeToolRenderer })))diff --git a/products/skills/frontend/LLMSkillScene.tsx b/products/skills/frontend/LLMSkillScene.tsxindex 6869f0491f73..9177975a3284 100644--- a/products/skills/frontend/LLMSkillScene.tsx+++ b/products/skills/frontend/LLMSkillScene.tsx@@ -1,7 +1,7 @@import { useActions, useValues } from 'kea'import { Form } from 'kea-forms'import { combineUrl, router } from 'kea-router'-import { Fragment, lazy, Suspense, useEffect, useRef, useState } from 'react'+import { Fragment, Suspense, useEffect, useRef, useState } from 'react'import {IconChevronRight,@@ -25,6 +25,7 @@ import { LemonInput } from 'lib/lemon-ui/LemonInput'import { LemonMarkdownWithMermaid } from 'lib/lemon-ui/LemonMarkdown'import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'import { copyToClipboard } from 'lib/utils/copyToClipboard'+import { lazyWithRetry } from 'lib/utils/retryImport'import { SceneExport } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'@@ -43,7 +44,7 @@ import { SKILL_NAME_MAX_LENGTH, SKILL_DESCRIPTION_MAX_LENGTH } from './skillConsimport { skillFileLogic } from './skillFileLogic'import { openArchiveSkillDialog } from './skillSceneComponents'-const MonacoDiffEditor = lazy(() => import('lib/components/MonacoDiffEditor'))+const MonacoDiffEditor = lazyWithRetry(() => import('lib/components/MonacoDiffEditor'))export const scene: SceneExport<SkillLogicProps> = {component: LLMSkillScene,