fix(kusa): contribution APIを新Deno Deployへ移行し、Search API失敗時の全体エラーを修正 - #1375
Merged
Conversation
未認証のSearch APIはレート制限に達すると403を返すが、その応答の Access-Control-Allow-Originが不正な値(`*;`)のためブラウザがCORS違反として fetch自体をrejectする。`!res.ok`の分岐に到達せず例外が伝播していたため、 1リクエストの失敗でReact Queryがerror状態になりDetail全体が"Error"表示に なっていた。取得結果が空でもページは成立するので、失敗時は空配列に倒す。 e2e側もSearch APIのレート制限に依存して不安定だったためモックする。
Deno Deploy Classicが2026-07-20に停止し、参照していたupstreamの github-contributions-api.deno.devもフォールバック先のforked-gh-contributions-*.deno.devも DEPLOYMENT_NOT_FOUNDになっていた。結果としてToday/Yesterday/Streak/Coverageと OGのdescriptionがすべて`-`になっていたため、新Deno Deployへ移したデプロイ先を参照する。 生きている代替が存在しなくなったのでフォールバックのretry分岐は削除する。 同じ事故を検知できるよう、APIが落ちていてもページが表示され統計が`-`になることを e2eで固定する。
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Deno Deploy Classic の停止で参照できなくなっていた kusa の contribution API を、新 Deno Deploy へ移したデプロイ先に差し替える。あわせて、その検証中に見つかった Search API 失敗時に Detail 全体が壊れる問題を修正する。
why
contribution API の移行漏れ
Deno Deploy Classic が 2026-07-20 に停止し、参照していた2つのエンドポイントが両方とも死んでいた。
primary(upstream のデプロイ)が落ちたときのフォールバック先も同じ Classic 上にあったため、
/kusa/[username]の SSR は常に[null, null]を返し、Today / Yesterday / Streak / Coverage と OG の description がすべて-になっていた。Search API 失敗で Detail 全体がエラーになる
未認証の GitHub Search API は 10req/min で枯れる。その 403 応答は
Access-Control-Allow-Origin: *;という不正な値を返すため、ブラウザは CORS 違反としてfetch自体を reject する。search-api.tsはif (!res.ok) return []で握る作りだったが、reject ではその分岐に到達せず例外が伝播し、React Query が error 状態になって Detail 全体が "Error" 表示になっていた(curl では正常な*が返るためブラウザからしか再現しない)。how
pages/kusa/[username].tsxの参照先を、fork を新 Deno Deploy へデプロイしたhttps://forked-contributions-api.swfz.deno.netに変更toパラメータ / CORS・cache ヘッダ)なので他の変更は不要search-api.tsの3関数を共通ヘルパfetchSearchItemsに集約し、fetch が reject しても空配列に倒す-になる」ケースを追加(モックサーバーがdeadapiに 503 を返す)確認観点
toパラメータ / 最終要素が当日)og:descriptionに実データが入ること)-になること(e2e で固定)🤖 Generated with Claude Code