fix(docs): resolveDocPath 放宽超时+SSR UA+失败日志,修生产 404 自愈失效#356
Open
longsizhuo wants to merge 1 commit into
Open
Conversation
resolveDocPath 的 fetch 之前 400ms 超时太紧、catch 静默无日志, 导致 Vercel SSR 调后端 resolve 拿不到结果时静默降级 404,服务端 308 自愈在生产不生效(DB/后端/数据均已验证正常)。 - 超时 400ms → 2500ms(Vercel→CF→Oracle 跨区+冷缓存留余量) - 加 SSR UA + accept header(对齐 feed/page,规避 CF bot filter) - catch 与非 3xx 分支加 console.error(status/cf-ray/error), 便于从 Vercel 运行时日志定位真实失败原因
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes production doc-path self-healing redirects that were failing due to an overly aggressive resolveDocPath fetch timeout and silent error handling in the SSR docs page route.
Changes:
- Increase
resolveDocPathtimeout from 400ms to 2500ms to reduce false 404 fallbacks under cross-region/cold-cache latency. - Add
Accept: application/jsonand SSRUser-Agentheaders to align with existing Cloudflare-bypass conventions. - Add runtime logging for non-redirect responses and fetch failures to aid diagnosis via Vercel logs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
41
to
56
| const controller = new AbortController(); | ||
| const timeout = setTimeout(() => controller.abort(), 400); | ||
| // 跨区(Vercel→CF→Oracle)+ 后端冷缓存可能 >1s,400ms 太紧会误降级 404 | ||
| const timeout = setTimeout(() => controller.abort(), 2500); | ||
| const res = await fetch( | ||
| `${BACKEND_URL}/api/docs/resolve?path=${encodeURIComponent(strippedPath)}`, | ||
| { redirect: "manual", signal: controller.signal, cache: "no-store" }, | ||
| { | ||
| redirect: "manual", | ||
| signal: controller.signal, | ||
| cache: "no-store", | ||
| // 显式 UA:Vercel SSR 默认出口 UA 可能被 CF bot filter 拦(对齐 feed/page fetchLinks) | ||
| headers: { | ||
| accept: "application/json", | ||
| "user-agent": "InvolutionHell-SSR/1.0 (+https://involutionhell.com)", | ||
| }, | ||
| }, | ||
| ); |
Comment on lines
+66
to
+71
| // 非 3xx:记录真实状态,便于从 Vercel 日志定位(CF 403 / 后端异常等) | ||
| console.error("[docs/resolve] non-redirect status", { | ||
| path: strippedPath, | ||
| status: res.status, | ||
| cfRay: res.headers.get("cf-ray"), | ||
| }); |
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.
问题
服务端 308 自愈(6af9621)已部署生产,但旧 docs 路径仍 404。排查:DB 同步正常、后端 resolve 端点直连返回 301、各 UA 均不被 CF 拦。真凶锁定 resolveDocPath 内部:400ms 超时太紧 + catch 静默无日志。
改动
feed/page.tsxfetchLinks 规避 CF bot filter 的做法)console.error(status / cf-ray / error name),用于从 Vercel 日志确诊验证计划
preview 部署后 curl -I 旧路径应见 308;并读 Vercel runtime log 确认 fetch 真实结果。
🤖 Generated with Claude Code