fix(geo-map): load the leaflet engine client-side only - #156
Conversation
Merge as is — The SSR boundary and stale test mock are corrected; only review-thread resolution remains operationalThe current source graph keeps Prior findings
Merge state: The supplied status reports Evidence · 3 verified · 2 not verified · 4 carriedVerified
Not verified
Examined 8 of 9 changed files. Not read: 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
Comment Review by Rupic. |
There was a problem hiding this comment.
2 inline comments below, on apps/www/components/tool-ui/geo-map/geo-map.tsx (2).
Full review: #156 (comment)
There was a problem hiding this comment.
1 inline comment below, on apps/www/components/tool-ui/geo-map/geo-map-engine.tsx.
Full review: #156 (comment)
There was a problem hiding this comment.
1 inline comment below, on apps/www/components/tool-ui/geo-map/geo-map-engine.tsx.
Full review: #156 (comment)
problem
/docs/galleryreturns 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
windowat module scope.geo-map.tsximportedGeoMapEnginestatically, so any server render that reachesGeoMapevaluates leaflet and throwsReferenceError: window is not defined. the gallery page'snext/dynamicwrappers don't help: in a server componentdynamic()still SSRs andssr: falseisn't allowed there.change
load the engine inside
geo-map.tsx(a client component, wheressr: falseis legal) viadynamic(() => 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 leafletwindowstack. after the change:/docs/galleryand/docs/geo-mapboth 200, no new window errors in the dev log;pnpm --filter tool-ui-www buildgreen.