Skip to content

flaky: plugin-audit zh-CN 摘要与 cloud-connection marketplace seed 在整仓并发下偶发失败(单跑必过) #3785

Description

@os-zhuang

#3723 / PR #3747 期间两轮整仓 npx turbo test 各偶发失败不同的包,单独重跑及干净工作树上均通过。记录下来,免得下一个 agent 重新排查一遍 —— 我为排除自己的改动做了两轮 stash 对照才确认无关。

✅ 已解决(2026-07-30):两半都已定位根因并修复 —— plugin-audit 见 PR #4193,cloud-connection 见 PR #4217。结论见下方评论;两者是同一症状、不同根因

观测(2026-07-28,worktree 基于 #3747 分支,改动不涉及这两个包)

第一轮(turbo test,99 任务):

FAIL src/audit-writers.test.ts > audit writers — localized activity summaries (framework#3039)
     > localizes verb + object label to the workspace locale (zh-CN)
@objectstack/plugin-audit: Tests 1 failed | 45 passed (46)

第二轮(turbo test --continue,132 任务)—— plugin-audit 这轮通过,换 cloud-connection 挂:

FAIL src/marketplace-install-local-seed-lookup.test.ts > marketplace install — seed lookup resolution
     > writes target record ids (never raw externalId strings) for package objects unknown to the metadata service
FAIL src/marketplace-install-local-state-machine-exempt.test.ts > marketplace install — state_machine initialStates exemption (#3433)
     > lands every mid-lifecycle seed row (no initialStates rejection on the marketplace seam)
@objectstack/cloud-connection: Tests 2 failed | 62 passed (64)

对照:

  • turbo test --filter=@objectstack/plugin-audit --force → 46/46 通过
  • turbo test --filter=@objectstack/cloud-connection --force → 64/64 通过
  • git stash -u 后干净树上两包同跑 → 全过

归类

#3060 / #3662 同一类:仅在整仓满并行负载下出现,单包必绿。两处都是会启动真实 kernel 的重型测试,疑似负载下的时序/资源争用,但未定位根因 —— 本 issue 首先是记录,其次才是修复请求。

失败断言本身值得看一眼的线索:

建议

按前例(#3662 的处理方式)排查:若是超时类,对齐兄弟用例的显式 timeout;若是真竞态,则是产品 bug 不是测试 bug,需要升级处理。

按 AGENTS.md Prime Directive #10 立此 issue;发现于 #3747 的验证过程,与该 PR 改动无关。


结案摘要(2026-07-30)

上面那条"建议"里的分诊二分法是对的,两半都落在超时类,但根因不同——i18n bundle 的异步加载是否有竞态这个猜测方向也对了一半:确实是异步加载,但是异步模块加载,不是数据竞态。

plugin-audit(#4193 cloud-connection(#4217
冷导入位置 测试文件自己的 helper 生产代码 install handler(故意不 mock,为了让 mock 能介入)
能否根治 能 —— 提为顶层静态 import 不能 —— 动态导入是有意设计,不该为测试改产品代码
处置 20347ms → 1ms,删掉 timeout 覆盖 预算 30s → 120s,对齐兄弟用例

两处都不是竞态:断言均通过,失败形态是纯超时。整仓 pnpm test 现已 132/132、退出码 0

一条留给后来者的经验:marketplace-install-local-seed-lookup 早在此前就已被单独修好(提到 120s 并留下"an import stall, not a hang"的诊断注释),但修复没有推广到同包的兄弟用例,于是本 issue 的另一半又挂了三个月。同类修复记得扫一遍同源用例——判据是 {不 mock 该模块} ∩ {真正走到那条路径}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions