Skip to content

fix(site): make docs build resilient to remote badge fetch failures (#2695)#2718

Merged
os-zhuang merged 1 commit into
mainfrom
fix/2695-docs-remote-image-resilience
Jul 20, 2026
Merged

fix(site): make docs build resilient to remote badge fetch failures (#2695)#2718
os-zhuang merged 1 commit into
mainfrom
fix/2695-docs-remote-image-resilience

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Closes #2695

问题

Build Docs(@object-ui/site#build)用 fumadocs 的 remark-image 插件在构建期拉取每一张远程图片以取得尺寸(getImageSize)。远程徽章(shields.io / skills.sh)因此把一个外部服务的可用性变成了构建的硬依赖——shields.io 一抖(Cloudflare 520 / 1200 "Too many requests")就抛错并让整个 docs 构建失败,与 PR 内容无关(见 #2684)。

根因定位

  • 全仓 content/docs 里唯一活跃触发构建期拉取的远程徽章是 content/docs/guide/agent-skills.md:12 的 skills.sh 徽章。
  • issue 里提到的 shields.io 引用都在代码围栏内(plugins/plugin-markdown.mdx),不会被 remark-image 处理。
  • 本地图片(dashboard-filters.md/img/*.png)在 Next.js bundler 流程里走 import 解析,不经过网络。

方案(issue 选项 1)

apps/site/source.config.tsremark-image 配置容错:

  • external: { timeout: 10_000 } —— 给每次远程拉取加超时,避免挂死的连接卡住 CI;
  • onError —— 远程图片取尺寸失败时告警而非 fail 构建;对本地/仓内图片仍然 throw(保持严格,坏路径照样卡构建)。

只加安全网,不改成功路径:远程可达时行为不变,徽章照常内联尺寸。

验收对照

  • shields.io(或任意远程图片源)不可用时,Build Docs 不再整体失败;
  • 定位并处理了触发拉取的具体徽章引用(skills.sh @ agent-skills.md:12)。

验证

直接用改后的真实 source.config.ts 驱动 fumadocs-coreremarkImage 跑失败 URL:

场景 旧行为 新行为
远程徽章 404/DNS 失败 THREW(构建失败) RESOLVED(告警,构建继续)✅
本地图片缺失 THREW THREW(仍然 fatal)✅

pnpm exec fumadocs-mdx 编译配置通过(接受 remarkImageOptions)。

@object-ui/site 在 changeset ignore 列表且属构建基础设施 bug 修复,无需 changeset。

🤖 Generated with Claude Code

…2695)

`Build Docs` (@object-ui/site#build) runs fumadocs' remark-image plugin,
which fetches every remote image at build time to inline its width/height.
For remote badges (shields.io / skills.sh) this turns an external service's
availability into a hard build dependency: a shields.io hiccup (Cloudflare
520 / 1200 "Too many requests") throws and fails the entire docs build,
unrelated to the PR under test (observed on #2684).

Configure remark-image via source.config.ts:
- external: { timeout: 10_000 } — bound each remote fetch so a hung
  connection can't stall CI.
- onError — warn (don't fail the build) when a remote image can't be sized,
  while re-throwing for local/authored images so broken in-repo paths stay
  fatal.

The only live remote badge triggering a build-time fetch is the skills.sh
badge in content/docs/guide/agent-skills.md; the shields.io references live
inside code fences and are never fetched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Jul 20, 2026 2:54am

Request Review

@github-actions github-actions Bot added the apps label Jul 20, 2026
@os-zhuang
os-zhuang merged commit dd8b72c into main Jul 20, 2026
4 checks passed
@os-zhuang
os-zhuang deleted the fix/2695-docs-remote-image-resilience branch July 20, 2026 02:59
os-zhuang added a commit that referenced this pull request Jul 20, 2026
…2721)

`useViewTabLabel()` (ViewTabBar) and `useViewLabel()` (ManageViewsDialog)
returned the raw `t()` result, typed `string | object` by i18next. Their
return values are rendered directly as React children and passed as
aria-labels at ~35 sites, so vite build's dts pass emitted TS2322
(`string | object` not assignable to ReactNode). plugin-view has no
type-check gate, so these did not fail the build — but if `t()` ever
resolves a key to an object, React throws and white-screens.

Coerce the resolved value with `String(v)` and annotate the helper's
return type as `string`. Same "i18n/expression value is string|object,
rendered raw → white-screen" class tracked separately from PR #2718.

Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build Docs 因远程徽章拉取(shields.io)零星失败——让 apps/site 构建对图片拉取故障健壮

1 participant