Skip to content

fix: install/sync 递归拷 hub-server 子目录,根治漏拷 routes/ 致 Hub 100% 崩 (#35)#39

Draft
NorveraFlorent wants to merge 1 commit into
LinekForge:mainfrom
NorveraFlorent:fix/install-sync-routes-subdir
Draft

fix: install/sync 递归拷 hub-server 子目录,根治漏拷 routes/ 致 Hub 100% 崩 (#35)#39
NorveraFlorent wants to merge 1 commit into
LinekForge:mainfrom
NorveraFlorent:fix/install-sync-routes-subdir

Conversation

@NorveraFlorent
Copy link
Copy Markdown

关联 issue:LinekForge/forge-hub #35#38 是其重复件,已折入 doctor 建议)。

为什么

升级到 HEAD 后 forge-hub install 完成,但 launchd 拉起的 hub 立即崩:

error: Cannot find module './routes/health.js' from '/Users/<...>/.forge-hub/endpoints.ts'

根因:cli.tscpDir非递归的(readdirSync 一层 + stat.isFile(),遇子目录直接跳过)。install/sync 部署 hub-server 时只显式拷了顶层文件 + channels/漏了 routes/。而 endpoints.ts 启动时 import './routes/health.js',运行时缺该目录 → 100% 崩,KeepAlive 陷崩溃循环刷爆 stderr。routes/ 是路由拆分后引入的子目录,installer 的硬编码拷贝清单没跟上这次重构。

(注:stagePackageRuntime 的 source→snapshot 已用递归 copyFilteredTree,故 package/hub-server/routes/ 完整;漏的是 snapshot→runtime 这一步。)

改了什么

  • copyFilteredTree 增加可选 skipNames 参数(与既有 cpDir 对齐)。
  • install / sync 的 hub-server 拷贝从非递归 cpDir 换成递归 copyFilteredTree排除 channels/(保留其原有 clean + chmod 700 路径),sync 额外保留 SYNC_SKIP。这样自动覆盖 routes/ 及未来任何新增子目录,根治"加子目录忘改 installer"的回归。
  • doctor 增加 "Hub routes/ deployed" 校验(检 routes/health.ts),避免漏拷后仍报 "All checks passed"(采纳 forge-hub install/sync 漏拷 hub-server/routes/ 子目录,导致 Hub 启动崩溃 #38 @AmberCXX 的建议)。

没改什么

  • channels/ 的 clean + chmod 700 安全路径不动。
  • sync 的 SYNC_SKIP(防同名 .json 覆盖用户运行时配置)语义不变。
  • 不动 cpDir(仍用于 hub-client 等顶层拷贝场景)。

怎么验

  • bun cli.ts --help 解析通过(项目无构建步骤,Bun 直跑 TS)。
  • 临时 HOME 跑 bun cli.ts doctor:缺 routes/ → ✗「Hub routes/ deployed」并给修复提示;补上 routes/health.ts → ✓。
  • 复刻补丁后的递归拷贝跑真实 hub-serverroutes/ 6 个文件全落、channels/ 正确排除、顶层文件照拷。
  • bun hub-test-harness/harness.ts:8/8 通过(无回归)。

🤖 Generated with Claude Code

…Forge#35)

## 为什么
install/sync 用非递归的 cpDir 拷 hub-server,只拷顶层 + 显式 channels/,
静默跳过 routes/。endpoints.ts 启动时 import './routes/health.js',运行时
缺该目录 → Hub 启动 100% 崩,KeepAlive 陷崩溃循环刷爆 stderr。根因是
endpoints.ts 拆分路由引入 routes/ 子目录后,installer 的硬编码拷贝清单没跟上。

## 改了什么
- copyFilteredTree 增加 skipNames 参数(与 cpDir 对齐)。
- install/sync 的 hub-server 拷贝从非递归 cpDir 换成递归 copyFilteredTree,
  排除 channels/(仍走原有 clean + chmod 700 路径),sync 额外保留 SYNC_SKIP。
  自动覆盖 routes/ 及未来任何新增子目录,根治"加子目录忘改 installer"的回归。
- doctor 增加 "Hub routes/ deployed" 校验(检 routes/health.ts),避免漏拷后
  仍报 All checks passed(LinekForge#38 建议,credit AmberCXX)。

## 没改什么
- channels/ 的 clean + chmod 700 安全路径不动。
- sync 的 SYNC_SKIP 用户配置保护语义不变。

## 怎么验
- 临时 HOME 跑 doctor:缺 routes/ → ✗ 并给修复提示;补上 → ✓。
- 复刻补丁后的递归拷贝跑真实 hub-server:routes/ 6 文件全落、channels/ 正确排除。
- bun hub-test-harness/harness.ts:8/8 通过(无回归)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@NorveraFlorent NorveraFlorent force-pushed the fix/install-sync-routes-subdir branch from 6b7322e to ffbeff1 Compare May 30, 2026 10:35
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.

1 participant