Skip to content

fix(ci): 修复 ootb workflow 持续失败 — check-catalog ESM 崩溃、db-server 入口路径、模块启停缓存#7

Closed
cursor[bot] wants to merge 6 commits into
mainfrom
cursor/bc-c563c7d6-b06d-459b-9771-eec95180d967-d850
Closed

fix(ci): 修复 ootb workflow 持续失败 — check-catalog ESM 崩溃、db-server 入口路径、模块启停缓存#7
cursor[bot] wants to merge 6 commits into
mainfrom
cursor/bc-c563c7d6-b06d-459b-9771-eec95180d967-d850

Conversation

@cursor

@cursor cursor Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

背景

ootb workflow 在 push 到 main 后持续失败(近期所有记录到的 run 均为失败,无一次成功),本次触发失败的 commit 为 f5eee5c。审查后定位到多个独立且可复现的 bug,均已在本地完整跑通 check-ootb.js 全部 6 项检查 + smoke-modules.js 全部断言(修复前为 通过2/失败4,修复后为 通过6/失败0,smoke 全部通过)。

根因与修复

  1. tools/check-catalog.js 用 ESM import,但仓库是 CommonJS — 根 package.json 未声明 "type": "module"tools/ 下其它脚本全部用 require。直接 node tools/check-catalog.js 必定抛出 SyntaxError: Cannot use import statement outside a module,导致 check-ootb 第 3 项检查必然失败。改为 CommonJS,风格与同目录脚本保持一致。

  2. db-server 入口路径写错tools/check-ootb.jstools/sim-new-user.js 都 spawn db-server/index.js,但该文件从未存在,真实入口是构建产物 db-server/dist/index.jsdb-server/package.json#mainsfmc/src/runtime.tssfmc/src/dispatcher.tsservices/catalog.json 均已如此引用)。导致 check-ootb 的“db-server 启动”与“sim-new-user 全流程”两项检查必然失败(后者会 60s 超时)。已改为正确路径。

  3. configs-default/db_config.jsonmodulesDir 解析到仓库外 — 默认值 "../modules" 相对 PROJECT_ROOT(仓库根)再向上一级,指向仓库外不存在的目录,会导致模块 API 返回空 catalog。改为 "modules",等价于省略该字段时的默认回退行为。

  4. CI 从未创建 configs/configs/.gitignore 忽略,ootb.yml 里也没有生成它的步骤,导致 check-ootb 第 1 项“必备仓库文件齐全”(要求 configs/db_config.json 等 3 个文件存在)在每次 CI 运行中都会失败。新增一步在 build 之后、check-ootb 之前,把 configs-default/*.json 复制到 configs/(仅当目标文件不存在时才复制,不影响已有配置)。

  5. db-server 模块启停接口读己之写不一致(额外发现的真实 bug) — 上述问题修复后 check-ootb 才能跑通,从而让 smoke-modules 步骤真正执行到(此前因 check-ootb 失败而被 GitHub Actions 直接跳过,从未被验证过)。跑起来后发现 POST /api/sfmc/modules/:id/{enable|disable} 返回体里的 module.enabled 字段始终是切换前的旧值:setModuleEnabled() 每次都从磁盘重新读取、更新并写回 lock 文件,但模块级常量 lockFilebuildModuleList() 读取的就是它)从未被刷新,导致内存缓存与刚写入的磁盘状态不一致。修复为写盘后同步刷新 lockFile

  6. .gitignore 遗漏几个 dist/ 目录qq-bridge/sfmc/remote-controller/ 都会通过 tsc 产出 dist/,但 .gitignore 里只覆盖了 bds-toolsdb-serverpanel(已不存在),补全遗漏项,避免本地构建后被误加入 git。

验证

本地完整复现 CI 步骤(npm installnpm run build --workspaces --if-present → 复制 configs-default/node tools/check-ootb.js → 启动 db-server/dist/index.jsnode tools/smoke-modules.js):

  • 修复前:check-ootb 通过 2 / 失败 4(缺少必备文件、check-catalog 崩溃、db-server 不可达、sim-new-user 超时)
  • 修复后:check-ootb 通过 6 / 失败 0;smoke-modules.js 全部断言通过(包含之前从未被执行过的 enable/disable 翻转断言)
  • cd db-server && npm run typecheck 通过

影响范围

仅涉及 CI 脚本、默认配置模板、以及 db-server 里一处内存缓存刷新逻辑;未改动任何模块业务逻辑或运行时行为契约。

Open in Web View Automation 

cursoragent and others added 6 commits July 21, 2026 17:14
根目录 package.json 未声明 "type": "module",check-catalog.js 却用
ESM import 语法,导致 node 直接执行时抛出
"SyntaxError: Cannot use import statement outside a module"。
tools/ 下其余脚本均为 CommonJS,统一风格并修复 check-ootb CI 检查项。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
check-ootb.js 与 sim-new-user.js 均直接 spawn db-server/index.js,
但该文件不存在 —— db-server 编译后的真实入口是 dist/index.js
(package.json#main / sfmc/src/runtime.ts / dispatcher.ts 均已如此引用)。
之前一直因路径错误导致 db-server 无法启动、sim-new-user 超时。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
configs-default/db_config.json 的 modulesDir 原为 "../modules",
会相对 PROJECT_ROOT(仓库根)再向上一级解析,指向仓库外不存在的目录,
导致模块 API 返回空 catalog。改为 "modules" 以正确指向 <root>/modules
(与省略该字段时的默认回退行为一致)。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
setModuleEnabled() 每次都从磁盘重新读取 lock 文件、更新并写回,
但内存中长期持有的 lockFile 变量从未被刷新 —— buildModuleList()/current()
读取的一直是旧引用,导致 POST /api/sfmc/modules/:id/{enable|disable}
接口返回的 module.enabled 字段仍是切换前的状态(尽管磁盘已写入正确值)。
写盘后同步刷新 lockFile,使接口的读己之写立即可见。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
configs/ 已被 .gitignore 忽略,CI checkout 后该目录始终不存在,
导致 check-ootb.js 的"必备仓库文件齐全"检查(要求
configs/db_config.json 等三个文件存在)每次都失败。
新增一步在构建之后、检查之前把 configs-default/*.json 复制到
configs/(仅当目标文件不存在时),与本地开发环境的标准初始化步骤一致。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
这三个 workspace 都会通过 tsc 产出 dist/,但 .gitignore 里只有
bds-tools、db-server、panel(已不存在)三项,遗漏了它们,
本地构建后会被 git 当作未跟踪文件提示。

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
@Tanya7z

Tanya7z commented Jul 22, 2026

Copy link
Copy Markdown
Member

Superseded by main tools rewrite (e6525bb) and PR #17 CI/registry fixes. Closing as duplicate/outdated.

@Tanya7z Tanya7z closed this Jul 22, 2026
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