Skip to content

fix(geo-map): load the leaflet engine client-side only - #156

Merged
okisdev merged 5 commits into
mainfrom
fix/geo-map-ssr
Aug 31, 2026
Merged

fix(geo-map): load the leaflet engine client-side only#156
okisdev merged 5 commits into
mainfrom
fix/geo-map-ssr

Conversation

@okisdev

@okisdev okisdev commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

problem

/docs/gallery returns 500 on every uncached full-document request (80 x 500 in 24h, surfaced by the Axiom "Vercel long-tail 5xx" monitor; beehiiv newsletter referrals and crawlers keep hitting it). RSC prefetches served from cache still 200, which masked it.

root cause

leaflet reads window at module scope. geo-map.tsx imported GeoMapEngine statically, so any server render that reaches GeoMap evaluates leaflet and throws ReferenceError: window is not defined. the gallery page's next/dynamic wrappers don't help: in a server component dynamic() still SSRs and ssr: false isn't allowed there.

change

load the engine inside geo-map.tsx (a client component, where ssr: false is legal) via dynamic(() => import("./geo-map-engine"), { ssr: false }). leaflet never evaluates on the server again, and every GeoMap consumer (gallery, docs page, preset selector) inherits the guard at the component seam. the existing fixed-height wrapper keeps layout stable until hydration.

verification

reproduced locally first: dev server GET /docs/gallery → 500 with the leaflet window stack. after the change: /docs/gallery and /docs/geo-map both 200, no new window errors in the dev log; pnpm --filter tool-ui-www build green.

Track in Rupic

@rupic-app

rupic-app Bot commented Aug 31, 2026

Copy link
Copy Markdown

Comment Reviewed in 2m 31s · Round 5 · comment · 660ea3d

Merge as is — The SSR boundary and stale test mock are corrected; only review-thread resolution remains operational

The current source graph keeps GeoMapEngine behind dynamic(..., { ssr: false }), removes Leaflet from _adapter, and the interdiff retargets the spatial test mock to _leaflet-adapter, so no code changes are required before merge. The supplied metadata still marks the two geo-map-engine.tsx review threads unresolved; please resolve those threads for operational readiness. Route and build behavior was not executed in this review.

Prior findings

Finding Status
apps/www/components/tool-ui/geo-map/geo-map-engine.tsx:16 Resolved — The interdiff updates apps/www/lib/tests/tool-ui/geo-map/spatial.test.ts to mock _leaflet-adapter, matching the engine's current import and closing the stale mock-path finding.

Merge state: The supplied status reports verify and Rupic code scan as successful, Rupic code review as null, and approval state is unknown; the two engine import threads remain marked unresolved.; blockers: Unresolved review thread at apps/www/components/tool-ui/geo-map/geo-map-engine.tsx:15.; Unresolved review thread at apps/www/components/tool-ui/geo-map/geo-map-engine.tsx:16.

Evidence · 3 verified · 2 not verified · 4 carried

Verified

  • The existing spatial test mocks the new Leaflet adapter path.
    The interdiff directly addresses the open prior finding by changing the mock module specifier.
  • The fixed-height wrapper keeps layout stable until hydration.
    The interdiff only changes the spatial test mock and does not touch the wrapper in geo-map.tsx.
  • The registry artifacts declare the added Next dependency and Leaflet adapter.
    The interdiff does not touch either registry artifact.

Not verified

  • The GeoMap facade loads the engine through a client-only boundary so Leaflet is not evaluated during SSR.
    The source graph supports the isolation, but this runtime claim was not executed in the delta pass; the interdiff does not touch the facade, engine, or adapters.
  • The reported /docs/gallery and /docs/geo-map responses are 200 and the package build is green.
    Those route and build results were not independently executed in this review, and the supplied status does not establish them separately.

Examined 8 of 9 changed files. Not read: apps/www/public/r/registry.json.

This delta pass reviewed the one-file interdiff, the current Geo Map facade, engine, adapters, overlays, SSR test, spatial test, registry item, and adjacent export/package surfaces. Nothing was executed, so the reported route responses and build result remain unverified; the changed section of apps/www/public/r/registry.json was not available in the truncated file read.

Round Commit Verdict Took When
1 2f0286c comment 1m 44s 2026-08-31 05:54 UTC
2 6195ef3 comment 2m 54s 2026-08-31 05:58 UTC
3 5b5835a comment 9m 11s 2026-08-31 06:15 UTC
4 c9e6c7b comment 2m 48s 2026-08-31 06:21 UTC
5 660ea3d comment 2m 31s 2026-08-31 06:27 UTC

Comment @rupic-app stop reviewing to stop reviewing this PR.

Review by Rupic.

@rupic-app rupic-app Bot added stage/needs-review No reviews yet; waiting for a maintainer app/www Changes an app under apps/ R1 Actionable, normal priority type/bugfix Bug fix size/XS Fewer than 10 lines changed stage/awaiting-author Changes requested or CI failing; ball is with the author R2 Ball is in the author's court; not actionable today and removed stage/needs-review No reviews yet; waiting for a maintainer R1 Actionable, normal priority labels Aug 31, 2026

@rupic-app rupic-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 inline comments below, on apps/www/components/tool-ui/geo-map/geo-map.tsx (2).

Full review: #156 (comment)

Comment thread apps/www/components/tool-ui/geo-map/geo-map.tsx
Comment thread apps/www/components/tool-ui/geo-map/geo-map.tsx
@rupic-app rupic-app Bot added stage/awaiting-reviewer Has reviews but not approved; reviewer follow-up needed R1 Actionable, normal priority size/S 10–49 lines changed and removed stage/awaiting-author Changes requested or CI failing; ball is with the author R2 Ball is in the author's court; not actionable today size/XS Fewer than 10 lines changed labels Aug 31, 2026
@rupic-app rupic-app Bot added size/M 50–199 lines changed stage/awaiting-author Changes requested or CI failing; ball is with the author R2 Ball is in the author's court; not actionable today and removed size/S 10–49 lines changed stage/awaiting-reviewer Has reviews but not approved; reviewer follow-up needed R1 Actionable, normal priority labels Aug 31, 2026

@rupic-app rupic-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline comment below, on apps/www/components/tool-ui/geo-map/geo-map-engine.tsx.

Full review: #156 (comment)

Comment thread apps/www/components/tool-ui/geo-map/geo-map-engine.tsx
@rupic-app rupic-app Bot added stage/awaiting-reviewer Has reviews but not approved; reviewer follow-up needed and removed stage/awaiting-author Changes requested or CI failing; ball is with the author labels Aug 31, 2026
@rupic-app rupic-app Bot added R1 Actionable, normal priority stage/awaiting-author Changes requested or CI failing; ball is with the author R2 Ball is in the author's court; not actionable today and removed R2 Ball is in the author's court; not actionable today stage/awaiting-reviewer Has reviews but not approved; reviewer follow-up needed R1 Actionable, normal priority labels Aug 31, 2026

@rupic-app rupic-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline comment below, on apps/www/components/tool-ui/geo-map/geo-map-engine.tsx.

Full review: #156 (comment)

Comment thread apps/www/components/tool-ui/geo-map/geo-map-engine.tsx
@rupic-app rupic-app Bot added stage/awaiting-reviewer Has reviews but not approved; reviewer follow-up needed R1 Actionable, normal priority and removed stage/awaiting-author Changes requested or CI failing; ball is with the author R2 Ball is in the author's court; not actionable today labels Aug 31, 2026
@okisdev
okisdev merged commit 1830bbc into main Aug 31, 2026
4 checks passed
@rupic-app rupic-app Bot added stage/merged Merged into the default branch and removed stage/awaiting-reviewer Has reviews but not approved; reviewer follow-up needed R1 Actionable, normal priority labels Aug 31, 2026
@okisdev
okisdev deleted the fix/geo-map-ssr branch August 31, 2026 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app/www Changes an app under apps/ size/M 50–199 lines changed stage/merged Merged into the default branch type/bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant