Skip to content

fix(docs): resolveDocPath 放宽超时+SSR UA+失败日志,修生产 404 自愈失效#356

Open
longsizhuo wants to merge 1 commit into
mainfrom
fix/docs-resolve-timeout-logging
Open

fix(docs): resolveDocPath 放宽超时+SSR UA+失败日志,修生产 404 自愈失效#356
longsizhuo wants to merge 1 commit into
mainfrom
fix/docs-resolve-timeout-logging

Conversation

@longsizhuo
Copy link
Copy Markdown
Member

问题

服务端 308 自愈(6af9621)已部署生产,但旧 docs 路径仍 404。排查:DB 同步正常、后端 resolve 端点直连返回 301、各 UA 均不被 CF 拦。真凶锁定 resolveDocPath 内部:400ms 超时太紧 + catch 静默无日志。

改动

  • 超时 400ms → 2500ms(Vercel→CF→Oracle 跨区 + 后端冷缓存余量)
  • fetch 加 SSR UA + accept header(对齐 feed/page.tsx fetchLinks 规避 CF bot filter 的做法)
  • catch 与非 3xx 分支加 console.error(status / cf-ray / error name),用于从 Vercel 日志确诊

验证计划

preview 部署后 curl -I 旧路径应见 308;并读 Vercel runtime log 确认 fetch 真实结果。

🤖 Generated with Claude Code

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 运行时日志定位真实失败原因
Copilot AI review requested due to automatic review settings May 25, 2026 06:41
@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
involutionhell-github-io Ready Ready Preview, Comment May 25, 2026 6:50am
website-preview Ready Ready Preview, Comment May 25, 2026 6:50am

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 resolveDocPath timeout from 400ms to 2500ms to reduce false 404 fallbacks under cross-region/cold-cache latency.
  • Add Accept: application/json and SSR User-Agent headers 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"),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants