Skip to content

fix(ci): 修复 ootb workflow 持续失败——ESM 崩溃、入口路径、缺失 configs 及 node:sqlite 版本门槛#12

Merged
Tanya7z merged 6 commits into
mainfrom
cursor/bc-d8a85948-0bc2-44b8-a375-7508e20cb028-37d3
Jul 22, 2026
Merged

fix(ci): 修复 ootb workflow 持续失败——ESM 崩溃、入口路径、缺失 configs 及 node:sqlite 版本门槛#12
Tanya7z merged 6 commits into
mainfrom
cursor/bc-d8a85948-0bc2-44b8-a375-7508e20cb028-37d3

Conversation

@cursor

@cursor cursor Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

背景

ootb workflow 在每次 push/PR 到 main 时都失败(触发本次自动化的 run: https://github.com/DogeLakeDev/ScriptsForMinecraftServer/actions/runs/29852681617 ,commit 3aead3a)。已存在多个未合并的重复修复 PR(#5#10),它们都修复了前 4 个根因,但它们自己的 CI 仍然失败(例如 #10 的 run https://github.com/DogeLakeDev/ScriptsForMinecraftServer/actions/runs/29852646408 ),因为还有第 5 个根因一直没被发现。本 PR 一次性修复全部 5 个根因,并在本地完整复现了 CI 流程验证 check-ootb 从 2/6 恢复到 6/6 全部通过。

根因 1—4(已被之前的 PR 独立发现,本 PR 同样包含)

  1. tools/check-catalog.js 用顶层 ESM import,但仓库根 package.json 没有 "type": "module"SyntaxError: Cannot use import statement outside a module。改成和其余 tools/*.js 一致的 CommonJS require()
  2. tools/check-ootb.js / tools/sim-new-user.js / tools/test-db-api.js 都 spawn 了不存在的 db-server/index.js,真正的产物入口是 db-server/dist/index.js
  3. configs-default/db_config.jsonmodulesDir 默认值是 "../modules",但它是相对 PROJECT_ROOT(仓库根)解析的,指向仓库外,导致模块 API 返回空列表。改成 "modules"
  4. CI 里 configs/ 从未被创建(gitignore),导致 check-ootb 的“必备仓库文件齐全”恒定失败,db-server 也因缺配置无法正常启动。workflow 里新增一步,在 build 之后、check-ootb 之前,从 configs-default/ 播种 configs/

根因 5(本 PR 新发现,此前所有修复 PR 都缺了这一条)

即使 1–4 全部修好,db-server 启动 + 模块接口 检查在 CI 上依然会超时失败——因为 db-server 在模块顶层 importnode:sqlite,而这个内置模块在 Node 22.5.0–22.12.x 上仍需要 --experimental-sqlite CLI 参数才能加载,直到 22.13.0 才默认可用(仍标记 experimental)。CI 的 actions/setup-node 之前固定 node-version: '22.5'(解析为 22.5.1),未带该参数直接 import 会抛出 ERR_UNKNOWN_BUILTIN_MODULE,db-server 进程立刻退出,端口 3001 永远起不来,check-ootb 等 15s 超时报「db-server 不可达」,sim-new-user.js 跟着超时。仓库里到处写的“Node 22.5+ 就够”(AGENTS.md / CLAUDE.md / README*.md / docs/user-guide.*.md / sfmc/src/runtime.ts 注释 / db-serverassertNodeVersion(22, 5) 版本门槛)都是同一个错误认知的重复体现。

修复:

  • .github/workflows/ootb.ymlsetup-node 固定到 22.13
  • db-server/package.json engines.node 改为 >=22.13.0db-server/src/index.tsassertNodeVersion(22, 5) 改为 assertNodeVersion(22, 13)(默认值同步更新,并补充注释说明该门槛因 ESM import 提升顺序无法拦住 lib/sqlite.ts 自身的 import 崩溃,主要作为文档/兜底用途)。
  • 统一更正 AGENTS.mdCLAUDE.mdREADME.md/README.en.mddocs/user-guide.zh.md/docs/user-guide.en.mdHANDOFF.mdsfmc/src/runtime.ts 注释里所有“Node 22.5+”的错误表述为“22.13+”。

附带修复

  • tools/test-db-api.js(未接入 CI,但同样命中根因 2/3)一并修好,避免以后被启用时踩同样的坑。
  • .gitignore 补上 qq-bridge/dist/sfmc/dist/,与其余 workspace 的 dist/ 保持一致。

验证

本地完整复现 CI 流程(npm installnpm run build --workspaces --if-present → 播种 configs/node tools/check-ootb.js):

[ootb] PASS: 必备仓库文件齐全
[ootb] PASS: 工具脚本齐全
[ootb] PASS: check-catalog 通过
[ootb] PASS: db-server 启动 + 模块接口
[ootb] PASS: sim-new-user 全流程通过
[ootb] PASS: sfmc CLI module 子命令已注册

[ootb] 通过 6 / 失败 0

此前(本 PR 修复前)是 通过 2 / 失败 4。另外单独起了 db-server 跑了一遍 node tools/smoke-modules.js,全部通过;npm run typecheck --workspace db-servernode --test db-server/dist/runtime.test.js 也都通过。

遗留说明

目前 main 上已经堆积了多个内容大部分重叠、均未合并的 fix(ci) PR(#5#10)。建议维护者合并本 PR(包含前 4 个根因 + 缺失的第 5 个根因)后关闭其余重复 PR,避免继续累积。

Open in Web View Automation 

cursoragent and others added 6 commits July 21, 2026 17:36
Root package.json has no "type": "module", so top-level ESM import
syntax throws "Cannot use import statement outside a module" under
plain node. This crashed tools/check-ootb.js's check-catalog step on
every CI run. Match the CommonJS style used by every other tools/*.js
script.

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
db-server/index.js does not exist — the compiled entry is
db-server/dist/index.js (per package.json main/start script). This
made check-ootb's db-server startup check and sim-new-user.js time out
waiting for the health endpoint, cascading into further failures.

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
modulesDir is resolved relative to PROJECT_ROOT (repo root), so "../modules"
pointed one directory above the repo and made the module API return an
empty catalog. The correct relative value is "modules".

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
Two independent bugs made the ootb workflow fail on every run:

1. configs/ is gitignored and never existed in CI, so check-ootb's
   required-files check and db-server startup both failed. Seed it
   from configs-default/ after the workspace build, mirroring the
   documented local setup step.
2. setup-node was pinned to node-version '22.5', which resolves to
   22.5.1. db-server imports node:sqlite at module scope, and that
   builtin is gated behind --experimental-sqlite on 22.5.0-22.12.x —
   importing it unflagged throws ERR_UNKNOWN_BUILTIN_MODULE and
   db-server exits immediately. This is why db-server never became
   reachable on port 3001 even after the entry-path fix, timing out
   check-ootb's db-server check and sim-new-user.js. node:sqlite lost
   the flag requirement in 22.13.0, so pin to that instead.

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
assertNodeVersion() defaulted to requiring only Node 22.5, but
node:sqlite (imported at module scope in lib/sqlite.ts) needs
--experimental-sqlite before 22.13.0 and throws
ERR_UNKNOWN_BUILTIN_MODULE without it. Raise the documented/enforced
floor to 22.13 to match reality; the guard still can't intercept the
sqlite import crash itself due to ESM import hoisting, so this is
mainly a correctness/documentation fix — the real enforcement point is
the CI node-version pin and local Node install docs.

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
node:sqlite requires --experimental-sqlite on Node 22.5.0-22.12.x and
is only unflagged from 22.13.0 onward. Every doc claiming '22.5+' was
technically wrong for db-server and directly contributed to the ootb
CI workflow pinning an unsupported version. Also ignore qq-bridge/dist/
and sfmc/dist/ like the other workspace dist/ folders.

Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
@Tanya7z
Tanya7z marked this pull request as ready for review July 22, 2026 01:23
@Tanya7z
Tanya7z merged commit a823baf into main Jul 22, 2026
1 check passed
@cursor

cursor Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

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