fix(ci): 修复 ootb workflow 持续失败——ESM 崩溃、入口路径、缺失 configs 及 node:sqlite 版本门槛#12
Merged
Tanya7z merged 6 commits intoJul 22, 2026
Merged
Conversation
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
marked this pull request as ready for review
July 22, 2026 01:23
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. |
This was referenced Jul 22, 2026
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/PR 到main时都失败(触发本次自动化的 run: https://github.com/DogeLakeDev/ScriptsForMinecraftServer/actions/runs/29852681617 ,commit3aead3a)。已存在多个未合并的重复修复 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 同样包含)
tools/check-catalog.js用顶层 ESMimport,但仓库根package.json没有"type": "module"→SyntaxError: Cannot use import statement outside a module。改成和其余tools/*.js一致的 CommonJSrequire()。tools/check-ootb.js/tools/sim-new-user.js/tools/test-db-api.js都 spawn 了不存在的db-server/index.js,真正的产物入口是db-server/dist/index.js。configs-default/db_config.json的modulesDir默认值是"../modules",但它是相对PROJECT_ROOT(仓库根)解析的,指向仓库外,导致模块 API 返回空列表。改成"modules"。configs/从未被创建(gitignore),导致 check-ootb 的“必备仓库文件齐全”恒定失败,db-server 也因缺配置无法正常启动。workflow 里新增一步,在 build 之后、check-ootb 之前,从configs-default/播种configs/。根因 5(本 PR 新发现,此前所有修复 PR 都缺了这一条)
即使 1–4 全部修好,
db-server 启动 + 模块接口检查在 CI 上依然会超时失败——因为db-server在模块顶层import了node:sqlite,而这个内置模块在 Node 22.5.0–22.12.x 上仍需要--experimental-sqliteCLI 参数才能加载,直到 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-server的assertNodeVersion(22, 5)版本门槛)都是同一个错误认知的重复体现。修复:
.github/workflows/ootb.yml:setup-node固定到22.13。db-server/package.jsonengines.node改为>=22.13.0;db-server/src/index.ts的assertNodeVersion(22, 5)改为assertNodeVersion(22, 13)(默认值同步更新,并补充注释说明该门槛因 ESM import 提升顺序无法拦住lib/sqlite.ts自身的 import 崩溃,主要作为文档/兜底用途)。AGENTS.md、CLAUDE.md、README.md/README.en.md、docs/user-guide.zh.md/docs/user-guide.en.md、HANDOFF.md、sfmc/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 install→npm run build --workspaces --if-present→ 播种configs/→node tools/check-ootb.js):此前(本 PR 修复前)是
通过 2 / 失败 4。另外单独起了 db-server 跑了一遍node tools/smoke-modules.js,全部通过;npm run typecheck --workspace db-server和node --test db-server/dist/runtime.test.js也都通过。遗留说明
目前 main 上已经堆积了多个内容大部分重叠、均未合并的
fix(ci)PR(#5–#10)。建议维护者合并本 PR(包含前 4 个根因 + 缺失的第 5 个根因)后关闭其余重复 PR,避免继续累积。