process.once build warningnext build 过程中出现 Edge Runtime 不支持 Node API 的告警:process.once。
在修复前的版本(例如 tag v0.4.1)上运行 bun run build 可看到 Edge Runtime 不支持 Node API 的告警,其 import trace 包含:
A Node.js API is used (process.once) which is not supported in the Edge Runtime.
Import traces:
./src/lib/async-task-manager.ts
./src/lib/price-sync/cloud-price-updater.ts
./src/instrumentation.ts
相关导入链路(import trace)包含:
src/lib/async-task-manager.tssrc/lib/price-sync/cloud-price-updater.tssrc/instrumentation.tsAsyncTaskManager:
process.env.NEXT_RUNTIME === "edge" 时跳过初始化,避免触发 process.once 等 Node-only API。cloud-price-updater:
AsyncTaskManager 的顶层静态 import。requestCloudPriceTableSync() 内部按需动态 import AsyncTaskManager,并在 Edge runtime 下直接 no-op。bun run lintbun run typecheckbunx vitest run tests/unit/lib/async-task-manager-edge-runtime.test.ts tests/unit/price-sync/cloud-price-updater.test.ts --coverage --coverage.provider v8 --coverage.reporter text --coverage.include src/lib/async-task-manager.ts --coverage.include src/lib/price-sync/cloud-price-updater.tsbun run build
process.once 相关告警如需回滚,优先按提交粒度回退(以 commit message 为准):
fix: skip async task manager init on edgefix: avoid static async task manager importtest: cover edge runtime task scheduling定位对应提交(示例):
git log --oneline --grep "fix: skip async task manager init on edge"
git log --oneline --grep "fix: avoid static async task manager import"
git log --oneline --grep "test: cover edge runtime task scheduling"
如果未来 Next/Turbopack 的静态分析行为变化导致告警回归,可将 Node-only 的 signal hooks 拆分到 *.node.ts(例如 async-task-manager.node.ts),并仅在 NEXT_RUNTIME !== "edge" 的分支里动态引入。
rg -n "process\\.once" src/lib/async-task-manager.ts
rg -n "NEXT_RUNTIME|NEXT_PHASE" src/lib tests
rg -n "requestCloudPriceTableSync" src/lib/price-sync/cloud-price-updater.ts tests/unit/price-sync/cloud-price-updater.test.ts
.codex/plan/ 与 .codex/issues/ 属于本地任务落盘目录,不应提交到 Git。