Skip to content

test(lint): give the lazy-deps dist probes the same cold-load timeout as their sibling (#3662) - #3708

Merged
os-zhuang merged 2 commits into
mainfrom
claude/lazy-deps-dist-probe-timeout-1v706g
Jul 27, 2026
Merged

test(lint): give the lazy-deps dist probes the same cold-load timeout as their sibling (#3662)#3708
os-zhuang merged 2 commits into
mainfrom
claude/lazy-deps-dist-probe-timeout-1v706g

Conversation

@os-zhuang

@os-zhuangos-zhuang commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Closes#3662.

问题

packages/lint/src/lazy-deps.test.ts 的两条 dist 探针(行 81 / 行 90)各自 spawn 一个子 node,在子进程里冷加载 sucrase(~1.5 MB)与 typescript(~9 MB),用来证明这两个依赖不会在 import 时被带进来。这个冷加载本身在整仓 pnpm test(几十个 turbo 任务并行)下就会超过 vitest 默认的 5s ——issue 里实测 ESM 那条在 execFileSync 上耗时 5928ms

失败纯粹是延迟:断言只检查"子进程的 require cache 里最终有哪些依赖",与耗时无关。

同一文件的 in-process 兄弟用例早就知道这件事,显式带了 30_000 并写了注释;两条 dist 探针做同样的冷加载却沿用默认 5s。

改动

把那段说明提成一个具名常量 COLD_LOAD_TIMEOUT_MS = 30_000,三条冷加载用例(两条 dist 探针 + in-process 兄弟)统一引用它。理由只写一次,不会再出现"兄弟改了、探针没改"的漂移。断言一行未动。

+// Every case below cold-loads sucrase + typescript (~1.5 MB / ~9 MB) — in-process+// for the behavioral case, in a spawned child `node` for the dist probes. On a+// loaded runner (dozens of parallel turbo tasks) that alone takes >5s, so vitest's+// default 5s timeout flakes while the assertion set is pure contract, not latency.+const COLD_LOAD_TIMEOUT_MS = 30_000;

验证

pnpm --filter @objectstack/lint... build 把 dist 构建出来,让两条 skipIf 探针真的跑起来而不是被跳过:

✓ built CJS dist does not load a lazy dep until a react page is validated 908ms
✓ built ESM dist does not load a lazy dep until a react page is validated 751ms
✓ loads each dep lazily in-process and the gates still work 3211ms

空载机器上 in-process 那条已经 3.2s,离 5s 很近 —— 与 issue 描述的负载下越界一致。

另外单独验证了"第三参数超时经由 it.skipIf(...) 确实生效"(vitest 4.1.10),用一次性探针跑同一段 6.5s 的 body:

✓ skipIf still honors a third-arg timeout (>5s default) 6509ms ← 带 30_000
× control: same body with the default 5s timeout must fail 5008ms → Test timed out in 5000ms.

该探针文件已删除,不在本 PR 内。

包内全量:32 test files / 447 tests passed;eslint packages/lint/src/lazy-deps.test.ts 干净。

关于 changeset

纯测试稳定性修复,不涉及运行时行为,按 AGENTS.md Post-Task Checklist #3 本身不需要发版说明。但 Check Changeset 门禁要求每个 PR 至少新增一个 changeset 文件,所以补了一个空 frontmatter 的 —— 工作流注释里明确把它列为"this PR releases nothing"的认可写法(仓库既有先例:.changeset/authz-ledger-flow-runas.md,同样是 test-only)。它声明的正是"不发版",与上面那条并不冲突。

… as their sibling (#3662)
The two dist probes spawn a child `node` that cold-loads sucrase (~1.5 MB) and
typescript (~9 MB) to prove neither comes in at import time. That cold load alone
exceeds vitest's default 5s timeout on a loaded runner — a whole-repo `pnpm test`
with dozens of parallel turbo tasks — so the ESM probe was observed failing at
5928ms on `execFileSync`. The failure is pure latency: the assertions only check
which deps ended up in the child's require cache.
The in-process sibling already knew this and carried an explicit 30s timeout. Hoist
that rationale into a single named `COLD_LOAD_TIMEOUT_MS` and apply it to all three
cold-loading cases, so the contract is stated once instead of drifting per case.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G71ANZMJ6TgX2a4WQVHmpr
@vercel

vercelBot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
objectstackIgnoredIgnoredJul 27, 2026 3:22pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/lint.

1 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/permissions/authorization.mdx(via @objectstack/lint)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

…ing (#3662)
Empty-frontmatter changeset — the sanctioned "this PR releases nothing"
declaration the Check Changeset gate looks for. The change is test-only.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G71ANZMJ6TgX2a4WQVHmpr
@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tooling labels Jul 27, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review July 27, 2026 15:28
@os-zhuang
os-zhuang merged commit 2b1d031 into mainJul 27, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the claude/lazy-deps-dist-probe-timeout-1v706g branch July 27, 2026 15:28
os-zhuang added a commit that referenced this pull request Jul 28, 2026
…clarations that never did (#3718) (#3840)
`client.ai` and the real AI service were disjoint sets: three methods whose
URLs no repo has ever mounted (deleted in v17) against 12 mounted routes with
no SDK expression. v17 closed the first half; this closes the second.
The SDK now expresses every AI route meant to be tenant surface — ai.chat /
ai.chatStream (POST /ai/chat, JSON | UI Message Stream), ai.complete,
ai.models, and ai.conversations.{create,list,get,update,delete,addMessage}.
`chat` forces `stream: false` because the endpoint streams by default;
`chatStream` returns a promise for an async iterable so the request (and any
HTTP error) happens on call, not on first iteration.
Breaking, and none of it had an implementation anywhere: the Ai{Nlq,Suggest,
Insights} schemas/types are replaced by the wire shapes of the real routes,
DEFAULT_AI_ROUTES is deleted (8 default registrations, not 9), and AiProtocol
is deleted — the real server contract is IAIService + IAIConversationService.
/api/v1/ai/ becomes a bounded prefix exemption in the capstone (#3642): only
`ai.*` may use it and the namespace must still be reaching it. The reachability
check lives where the routes are, in cloud's ai-route-ledger conformance test,
which reads buildAIRoutes() and drives this SDK against it. The wildcard-only
bound stays 0.
Refs #3718, #3708, #3642, #3563
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/steststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flaky: lazy-deps 的两条 dist 探针用例在整仓并发下撞 5s 默认超时(兄弟用例已设 30s)

2 participants

@os-zhuang@claude