Skip to content

fix(ui): ScaffaldLogo uses Math.random() for its gradient id, breaking hydration on every SSR page #582

Closed

Description

@thinkclay

ScaffaldLogo derives its SVG gradient id from Math.random(), so the server-rendered id never equals the client-rendered one. React discards the tree and re-renders the whole page on every load.

Evidence

packages/scf-core/assets/ScaffaldLogo.tsx:45

const gradientId = useMemo(
  () => `logo-gradient-${Math.random().toString(36).substring(2, 11)}`,
  []
)

Loading /profile in the dev server raises:

Uncaught Error: Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client.
packages/scf-core/assets/ScaffaldLogo.tsx (53:5) — <Svg …>, <Defs>, <LinearGradient id={gradientId}

The logo is in the app shell, so this fires on every SSR route, not just Profile.

Note

Likely related to #450 (public pages non-interactive on first load) — a discarded hydration tree loses the server-attached handlers until the client re-render completes.

Acceptance

  • gradientId uses React's useId() (stable across server and client).
  • /profile loads with no hydration error in the console.
  • Repo-wide check: no Math.random() or Date.now() in a render path of an SSR'd component.

Activity

  1. added
    bug
    agent-ready
    on Aug 12, 2026
  2. thinkclay commented on Aug 12, 2026

    @thinkclay
    ContributorAuthor

    Part of the profile-building audit rollup: #594

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Frontendagent-readybugpriority: hightype: frontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions