fix(ci): 修复 ootb workflow 持续失败 — check-catalog ESM 崩溃、db-server 入口路径、模块启停缓存#7
Closed
cursor[bot] wants to merge 6 commits into
Closed
fix(ci): 修复 ootb workflow 持续失败 — check-catalog ESM 崩溃、db-server 入口路径、模块启停缓存#7cursor[bot] wants to merge 6 commits into
cursor[bot] wants to merge 6 commits into
Conversation
根目录 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>
This was referenced Jul 21, 2026
Member
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.
背景
ootbworkflow 在 push 到main后持续失败(近期所有记录到的 run 均为失败,无一次成功),本次触发失败的 commit 为f5eee5c。审查后定位到多个独立且可复现的 bug,均已在本地完整跑通check-ootb.js全部 6 项检查 +smoke-modules.js全部断言(修复前为 通过2/失败4,修复后为 通过6/失败0,smoke 全部通过)。根因与修复
tools/check-catalog.js用 ESMimport,但仓库是 CommonJS — 根package.json未声明"type": "module",tools/下其它脚本全部用require。直接node tools/check-catalog.js必定抛出SyntaxError: Cannot use import statement outside a module,导致 check-ootb 第 3 项检查必然失败。改为 CommonJS,风格与同目录脚本保持一致。db-server入口路径写错 —tools/check-ootb.js和tools/sim-new-user.js都 spawndb-server/index.js,但该文件从未存在,真实入口是构建产物db-server/dist/index.js(db-server/package.json#main、sfmc/src/runtime.ts、sfmc/src/dispatcher.ts、services/catalog.json均已如此引用)。导致 check-ootb 的“db-server 启动”与“sim-new-user 全流程”两项检查必然失败(后者会 60s 超时)。已改为正确路径。configs-default/db_config.json的modulesDir解析到仓库外 — 默认值"../modules"相对PROJECT_ROOT(仓库根)再向上一级,指向仓库外不存在的目录,会导致模块 API 返回空 catalog。改为"modules",等价于省略该字段时的默认回退行为。CI 从未创建
configs/—configs/被.gitignore忽略,ootb.yml里也没有生成它的步骤,导致 check-ootb 第 1 项“必备仓库文件齐全”(要求configs/db_config.json等 3 个文件存在)在每次 CI 运行中都会失败。新增一步在 build 之后、check-ootb 之前,把configs-default/*.json复制到configs/(仅当目标文件不存在时才复制,不影响已有配置)。db-server模块启停接口读己之写不一致(额外发现的真实 bug) — 上述问题修复后check-ootb才能跑通,从而让smoke-modules步骤真正执行到(此前因 check-ootb 失败而被 GitHub Actions 直接跳过,从未被验证过)。跑起来后发现POST /api/sfmc/modules/:id/{enable|disable}返回体里的module.enabled字段始终是切换前的旧值:setModuleEnabled()每次都从磁盘重新读取、更新并写回 lock 文件,但模块级常量lockFile(buildModuleList()读取的就是它)从未被刷新,导致内存缓存与刚写入的磁盘状态不一致。修复为写盘后同步刷新lockFile。.gitignore遗漏几个dist/目录 —qq-bridge/、sfmc/、remote-controller/都会通过tsc产出dist/,但.gitignore里只覆盖了bds-tools、db-server、panel(已不存在),补全遗漏项,避免本地构建后被误加入 git。验证
本地完整复现 CI 步骤(
npm install→npm run build --workspaces --if-present→ 复制configs-default/→node tools/check-ootb.js→ 启动db-server/dist/index.js→node 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里一处内存缓存刷新逻辑;未改动任何模块业务逻辑或运行时行为契约。