fix: render athlete pages instead of 404ing on every profile#256
Conversation
The /athlete/[slug] edge page fetched a gzipped profile shard and relied on a hand-set `Content-Encoding: gzip` header so the HTTP layer would auto-decompress it. Vercel's CDN does not honor that header on public/ assets, so the edge fetch received raw gzip, `res.json()` threw, the failure was swallowed, and `getAthleteProfile` returned null β rendering a 404 for every real athlete (reproduced via search: Rootul Patel, 12 races, 404'd). It worked locally only because `next start` honors the header. - Serve athlete-shards as raw gzip (Content-Type: application/gzip, no Content-Encoding), mirroring the search shards. - Decompress explicitly in the edge runtime with fflate (pure JS β DecompressionStream is blocked in Next's edge runtime and zlib is Node-only). Detect the gzip magic bytes so it also handles servers that transfer-decompress the response. - Throw on a genuine load failure (non-ok / undecodable) instead of returning null, so a real athlete never renders a false "not found"; only a missing slug within a loaded shard is a true 404. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaVB6YHWz94LTY8AGVc88Q
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 9 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review detailsβοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: β Files ignored due to path filters (1)
π Files selected for processing (4)
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
Multiple users (a Reddit comment with 7 upvotes, then reproduced directly: searching Rootul Patel β
/athlete/rootul-patel--us-mβ 404, despite 12 real races) hit a 404 when clicking a search result through to an athlete's profile.Root cause
The
/athlete/[slug]edge page fetches a gzipped profile shard and relied on a hand-setContent-Encoding: gzipheader so the HTTP layer would auto-decompress it. Vercel's CDN does not honor that header onpublic/assets, so the edge fetch received raw gzip,res.json()threw, the failure was swallowed, andgetAthleteProfilereturnednullβnotFound()β a 404 for every real athlete. It worked locally only becausenext starthonors the header.The search shards already avoid this by decompressing explicitly β the athlete shards took the fragile shortcut.
Fix
athlete-shardsas raw gzip (Content-Type: application/gzip, noContent-Encoding), mirroring the search shards.fflate(pure JS βDecompressionStreamis blocked in Next's edge runtime andzlibis Node-only). Detect the gzip magic bytes so it also works where the server transfer-decompresses the response.null, so a real athlete never renders a false "not found"; only a missing slug within a successfully-loaded shard is a true 404.Testing
athlete-shards.test.ts(raw-gzip decode, already-decompressed body, throw-on-failure instead of false 404). Full suite: 160 passed, lint clean.π€ Generated with Claude Code