Skip to content

fix(results-panel): guard Recharts 0-width canvas crash on admin panel open#196

Merged
sacha-l merged 1 commit into
developfrom
fix/recharts-0-width-canvas
Jun 25, 2026
Merged

fix(results-panel): guard Recharts 0-width canvas crash on admin panel open#196
sacha-l merged 1 commit into
developfrom
fix/recharts-0-width-canvas

Conversation

@sacha-l

@sacha-l sacha-l commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds debounce={50} to ResponsiveContainer in FeedbackChart
  • Adds style={{ minWidth: 1 }} to the container div

Root cause

Recharts fires its first ResizeObserver measurement synchronously on mount, before the admin panel layout has settled. When the wallet unlocks and the admin section expands, the chart container is still in a CSS transition and reports width=0. Recharts then tries to create a Canvas gradient pattern on a 0×0 canvas, throwing InvalidStateError: Failed to execute 'createPattern' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.

debounce={50} defers the first measurement by 50ms, giving the layout time to settle. minWidth: 1 is a belt-and-suspenders guard so Recharts never receives a literal 0 even if the debounce doesn't fire in time.

Why it didn't catch in testing

  • The stadium-tester runs in mock mode where the admin panel is immediately visible (no layout transition) — the chart always gets a non-zero width on first render
  • The consoleErrors gate in the test spec catches errors that appear during test steps, but the Canvas error fires during mount before the wallet-unlock action completes, so it doesn't fail a specific expect()
  • No post-deploy smoke test runs against production after Railway swaps containers

Companion CORS error

The console also showed a CORS block on GET /api/programs/bitrefill-2026. That was transient — the Railway container swap caused a brief gap between old container going down and new container serving. Server is healthy; stadium.joinwebzero.com is explicitly in the CORS allowlist. No code change needed.

Test plan

  • Unlock admin panel on bitrefill-2026 in production, open the completed program → feedback charts render without console errors
  • cd client && npm run build — passes

…l open

Add debounce=50 and minWidth:1 to ResponsiveContainer in FeedbackChart.
Recharts fires its first resize measurement before the admin panel layout
settles, getting width=0, which causes createPattern to throw on a 0-dim
canvas. debounce defers the first render tick; minWidth prevents a 0 from
ever being reported.
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stadium Ready Ready Preview, Comment Jun 25, 2026 5:17pm

@sacha-l sacha-l merged commit d6ccea2 into develop Jun 25, 2026
2 checks passed
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.

1 participant