Skip to content

Keep the page when the Sankey search chunk fails to load - #286

Draft
posthog[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixweb-investigate-rising-chunk-load-84442b
Draft

posthog[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixweb-investigate-rising-chunk-load-84442b

Conversation

@posthog

@posthog posthog Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Problem

  • A visitor on a slow or broken connection loses the whole page when one optional widget fails to load. The Sankey chart on First Nations, federal, and provincial pages loads its search box (react-select) as a separate chunk.
  • A rejected next/dynamic import throws during render. The app has no error.tsx, so the error goes to global-error.tsx, which replaces the page with the generic Next.js error screen. That handler is also the posthog.captureException call that records the ChunkLoadError.
  • The recent rise is almost all one chunk: 9874.40d4186ce5fa533b.js, which is react-select. It comes from a small set of /en/first-nations/ISC_*/2024 pages.

Note

The rise probably comes from automated traffic, not from a broken deploy.

  • The chunk is still available: HTTP 200, immutable, Cloudflare cache HIT.
  • Webpack reports a chunk timeout only after 120 s. These exceptions arrive 0 to 4 s after the page view, so the client fast-forwards its timers. Headless browsers do this.
  • The sessions open 5 pages in the same second. They use a 1920 px viewport with no browser frame, and they come from Ashburn, San Jose, and Toronto.

Origin

  • Scout: signals-scout-general
  • First signal: 2026-09-28
  • Inbox report: open
  • Task started by: auto-start, after the report was rated P2 and ready to fix

Changes

  • The react-select loader now retries the import once. If the retry also fails, it resolves to an empty component. The chart stays on the page, and only the search box is absent.
  • The error no longer reaches the root boundary. The page stays intact, and this issue stops recording the event.
-const Select = dynamic(() => import("react-select"), {
+const Select = dynamic(
+  () =>
+    import("react-select")
+      .catch(() => import("react-select"))
+      .catch(() => () => null),

Risk

  • After a double failure, the search box is absent and nothing records the failure. The chart is still usable. Real users hit this rarely, so a silent fallback is better than an error screen.
  • This PR does not change other ChunkLoadError events: other chunks, other pages, and the buildcanada.com site. Those stay at the earlier background level.
  • Source maps stay unresolved for these frames. This PR does not change that.

Verification

I ran next dev (webpack) with Playwright on /en/federal/spending. In the blocked runs, Playwright stopped all requests for the react-select chunk.

Run Chunk requests Sankey chart Search box Error screen
main, chunk blocked 1 absent absent shown
This PR, chunk blocked 2 (with retry) shown absent absent
This PR, no block normal shown shown absent
  • pnpm test (64 tests) and pnpm lint pass.

Agent context

  • I rejected a CDN or cache fix: the deployed pages refer to assets that the server returns.
  • I rejected a static react-select import: the existing comment says that the dynamic import prevents SSR hydration mismatches.
  • Webpack clears a failed chunk from its cache, so the second import() requests the script again.

Created with PostHog Desktop from this inbox report.

🤖 Generated with Claude Code

The Sankey chart loads react-select with next/dynamic. When that chunk
fails, the rejected import reaches the root error boundary, and
global-error.tsx replaces the whole page. Retry the import once. If the
retry also fails, render no search box and keep the chart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: 77717744-4e69-4071-8073-86413ff6bd60
@build-canada-deploy-bot

Copy link
Copy Markdown

🚨 Preview Deployment Blocked - Security Protection

Your pull request was blocked from triggering preview deployments

Why was this blocked?

  • User: posthog[bot]
  • Repository: CanadaSpends
  • Permission Level: none
  • Required Level: write, maintain, or admin

How to resolve this:

Option 1: Get Collaborator Access (Recommended)
Ask a repository maintainer to invite you as a collaborator with write permissions or higher.

Option 2: Request Permission Override
Ask a repository administrator to disable security validation for this specific application if appropriate.

For Repository Administrators:

To disable this security check (⚠️ not recommended for public repositories):
Enter to preview settings and disable the security check.


This security measure protects against malicious code execution in preview deployments. Only trusted collaborators should have the ability to trigger deployments.

🛡️ Learn more about this security feature

This protection prevents unauthorized users from:

  • Executing malicious code on the deployment server
  • Accessing environment variables and secrets
  • Potentially compromising the infrastructure

Preview deployments are powerful but require trust. Only users with repository write access can trigger them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: 77717744-4e69-4071-8073-86413ff6bd60

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants