: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(app): explain and offer a reload on a stuck shell load (#94328)
posthog[bot]fba31957b751
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 07c579674688..712bb5d9e994 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -9040,6 +9040,10 @@ snapshots:hash: v1.k794b7964.701369c8815572e230847194697a10af64fbe3238b5ec2b97fb1ca472e921cb4.04vlOGhscYZQvQ0MZeCyfvHFER2HIhLpiFcH7AmsHrgscenes-other-account-connected--invalid-link--light:hash: v1.k794b7964.a339eb77db0b616ec64e77e675da285d292381ded8eb0daa201eb575dffa8e26.RETEKLpQHdGlg32dKsJCmtN5amqXJKpNRGo8i4c7RZU+ scenes-other-authenticatedshellfallback--stuck-shell--dark:+ hash: v1.k794b7964.701361424acc0289fd034abc12c8207144f480e0bdd22c0359465d4e7e51c7f0.qntozIS4u0U1agy-cU_rVXwzkp8CxJdr1wIPErK3gts+ scenes-other-authenticatedshellfallback--stuck-shell--light:+ hash: v1.k794b7964.64b80f73cd4551df9c88fa50f78d43b3a7eb89071afa6e170ef66c6844457260.EkrA0BMFtb6eGMjAeUgHv1rNiPEbAPlIBTFCz8Upt5Qscenes-other-billing--billing--dark:hash: v1.k794b7964.3aeba40d04a6226aeae25c8200dfc1bb74f34ba545f1294dab4293a63d7896c9.ANAwCdWwZqiMOI2A2gxChSERhIOiXhGfgnkygj1g1foscenes-other-billing--billing--light:diff --git a/frontend/src/scenes/App.tsx b/frontend/src/scenes/App.tsxindex d97560eb03f9..dddbb33ebbf5 100644--- a/frontend/src/scenes/App.tsx+++ b/frontend/src/scenes/App.tsx@@ -26,6 +26,7 @@ import { AppLoadError } from '~/layout/AppLoadError'import { ErrorBoundary } from '~/layout/ErrorBoundary'import { themeLogic } from '~/layout/navigation-3000/themeLogic'+import { AuthenticatedShellFallback } from './AuthenticatedShellFallback'import { ChunkLoadErrorBoundary } from './ChunkLoadErrorBoundary'const AuthenticatedShell = React.lazy(() => retryImport(() => import('./AuthenticatedShell')))@@ -203,14 +204,7 @@ function AppScene(): JSX.Element | null {return (<ChunkLoadErrorBoundary fallback={(error) => <AppLoadError error={error} />}>- <Suspense- fallback={- // SpinnerOverlay is already imported here — no new lazy deps vs skeleton.- <div className="relative h-screen">- <SpinnerOverlay sceneLevel />- </div>- }- >+ <Suspense fallback={<AuthenticatedShellFallback showSpinner={showingDelayedSpinner} />}><AuthenticatedShell>{wrappedSceneElement}</AuthenticatedShell></Suspense></ChunkLoadErrorBoundary>diff --git a/frontend/src/scenes/AuthenticatedShellFallback.stories.tsx b/frontend/src/scenes/AuthenticatedShellFallback.stories.tsxnew file mode 100644index 000000000000..c62571be5806--- /dev/null+++ b/frontend/src/scenes/AuthenticatedShellFallback.stories.tsx@@ -0,0 +1,23 @@+import { Meta } from '@storybook/react'++import { AuthenticatedShellFallback } from './AuthenticatedShellFallback'++const meta: Meta<typeof AuthenticatedShellFallback> = {+ title: 'Scenes-Other/AuthenticatedShellFallback',+ component: AuthenticatedShellFallback,+ parameters: {+ layout: 'fullscreen',+ testOptions: {+ // The fallback is itself a loader, so never wait for the spinner to disappear.+ waitForLoadersToDisappear: false,+ // Wait past the retry delay so the snapshot captures the explained, actionable state.+ waitForSelector: '[data-attr="authenticated-shell-fallback-reload"]',+ waitForSelectorTimeout: 12000,+ },+ },+}+export default meta++export function StuckShell(): JSX.Element {+ return <AuthenticatedShellFallback showSpinner />+}diff --git a/frontend/src/scenes/AuthenticatedShellFallback.test.tsx b/frontend/src/scenes/AuthenticatedShellFallback.test.tsxnew file mode 100644index 000000000000..941636a7703d--- /dev/null+++ b/frontend/src/scenes/AuthenticatedShellFallback.test.tsx@@ -0,0 +1,59 @@+import '@testing-library/jest-dom'++import { act, cleanup, render, screen } from '@testing-library/react'++import { AuthenticatedShellFallback } from './AuthenticatedShellFallback'++describe('AuthenticatedShellFallback', () => {+ beforeEach(() => {+ jest.useFakeTimers()+ })++ afterEach(() => {+ cleanup()+ jest.useRealTimers()+ })++ it('takes spinner visibility from the app-level delay instead of restarting it', () => {+ const { container, rerender } = render(<AuthenticatedShellFallback showSpinner={false} />)++ act(() => {+ jest.advanceTimersByTime(2000)+ })+ expect(container.querySelector('.Spinner')).toBeNull()++ rerender(<AuthenticatedShellFallback showSpinner />)+ expect(container.querySelector('.Spinner')).not.toBeNull()+ })++ it('holds the reload prompt back until the shell load is clearly stuck', () => {+ render(<AuthenticatedShellFallback showSpinner />)++ expect(screen.queryByText('Reload')).not.toBeInTheDocument()++ act(() => {+ jest.advanceTimersByTime(8000)+ })++ expect(screen.getByText('Reload')).toBeInTheDocument()+ })++ it('reloads the page when the person clicks reload', () => {+ const reload = jest.fn()+ Object.defineProperty(window, 'location', {+ configurable: true,+ value: { ...window.location, reload },+ })++ render(<AuthenticatedShellFallback showSpinner />)+ act(() => {+ jest.advanceTimersByTime(8000)+ })++ act(() => {+ screen.getByText('Reload').click()+ })++ expect(reload).toHaveBeenCalledTimes(1)+ })+})diff --git a/frontend/src/scenes/AuthenticatedShellFallback.tsx b/frontend/src/scenes/AuthenticatedShellFallback.tsxnew file mode 100644index 000000000000..80dc738754f8--- /dev/null+++ b/frontend/src/scenes/AuthenticatedShellFallback.tsx@@ -0,0 +1,48 @@+import { useEffect, useState } from 'react'++import { LemonButton } from 'lib/lemon-ui/LemonButton'+import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'++// After this long the shell is almost certainly stuck (a stale-deploy chunk that+// never resolves), so explain the wait and offer a reload.+const RETRY_PROMPT_DELAY_MS = 8000++/**+ * Suspense fallback for the authenticated shell chunk. It shows a spinner, then+ * explains the wait and offers a reload once the load is clearly stuck. This keeps+ * a hard reload after a stale-deploy chunk swap from leaving the person on a bare+ * full-screen logo with no way forward.+ *+ * `showSpinner` comes from `appLogic.showingDelayedSpinner`, which starts its delay+ * at app boot. The boot spinner can therefore be on screen before this fallback+ * mounts. A second delay timed from mount would hide the spinner again and blank+ * the screen between the two.+ */+export function AuthenticatedShellFallback({ showSpinner }: { showSpinner: boolean }): JSX.Element {+ const [showRetryPrompt, setShowRetryPrompt] = useState(false)++ useEffect(() => {+ const retryTimer = window.setTimeout(() => setShowRetryPrompt(true), RETRY_PROMPT_DELAY_MS)+ return () => clearTimeout(retryTimer)+ }, [])++ return (+ <div className="h-screen bg-primary flex flex-col items-center justify-center gap-3 text-center p-4">+ {showSpinner && <Spinner className="text-5xl" />}+ {showRetryPrompt && (+ <>+ <p className="max-w-100 text-secondary">+ PostHog is taking longer than usual to load. This can happen right after a new version ships.+ </p>+ <LemonButton+ type="primary"+ data-attr="authenticated-shell-fallback-reload"+ onClick={() => window.location.reload()}+ >+ Reload+ </LemonButton>+ </>+ )}+ </div>+ )+}