Repository navigation
Commit dbf53ef
test(ui): repository walkers tolerate tsup's transient bundled config vanishing mid-walk (#30357)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBFipqCKL82rffBrxJjboxqk)_
Fixes #30256
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:三个扫描整个仓库的测试,读文件时不再因为 tsup 构建临时写入又删掉的 `tsup.config.bundled_*.mjs`
而报 ENOENT;只改测试文件,不改产品代码。
- 为什么改:`strict-authoring-face-8345` 在合并队列里与并行分片的 tsup 构建竞态(队列构建
41962914067,`Test UI (4/16)`),把无关 PR 踢出队列。
- 风险与回滚:只容忍 ENOENT(读之前文件消失);其他读错误照样抛出,`scanned > 1000`
和唯一导入者断言一字未改。回滚即还原本 PR。
- 先看:`strict-authoring-face-8345.test.ts` 中提取出的 `scanForImporters` /
`readIfPresent` 和新增的竞态钉子测试。
- 两分钟验证:`cd ui && pnpm exec vitest run
packages/types/src/__tests__/strict-authoring-face-8345.test.ts`,预期 33
例全绿。
- 需要你做的:无,席位审阅并落地。
## What changes
-
**`ui/packages/types/src/__tests__/strict-authoring-face-8345.test.ts`**
— the importer walk is extracted to `scanForImporters(repoRoot, roots,
list?)` inside the same `describe`. Two guards, placed as #20225 /
#20269 placed them:
- a file named `*.bundled_<hash>.mjs` (tsup's transient bundle of
`tsup.config.ts`) is skipped by name;
- `readIfPresent` returns `undefined` on **ENOENT only** and the file is
not counted; every other read fault re-throws.
- `scanned` now counts files actually read (it used to count before the
read). The `scanned > 1000` floor and the
`['packages/types/src/zod/index.zod.ts']` importer assertion are
unchanged.
- **New race pin** in the same file drives the extracted walker over a
temp directory with a doctored listing: a vanished
`tsup.config.bundled_x.mjs` and a vanished `vanished.ts` → no throw,
`scanned: 1`, only `pkg/real.ts` found; an on-disk
`tsup.config.bundled_y.mjs` carrying a specifier → skipped by name; a
directory listed as a file → still throws `EISDIR`. The fixture's import
line is split so this file never reads as an importer itself.
- **Sweep, same race, fixed here** (walk reaches `ui/packages/cli`, a
tsup package root, and reads `.mjs`):
-
`ui/packages/app-shell/src/views/metadata-admin/previews/__tests__/block-config-i18n.test.ts`
(`shippedLiteralKeys`, walks `packages` + `apps`, ext
`(ts|tsx|js|jsx|mjs)`).
-
`ui/packages/app-shell/src/__tests__/select-placeholder-literal-11252.test.ts`
(walks `packages` + `apps`, `SOURCE_FILE` includes `mjs`; `filesRead`
now counts files actually read).
- Each got the same two guards inline. No shared helper: the three sites
live in two packages and a cross-package test import would add a
dependency edge for ten lines.
## Why
tsup bundles each package's `tsup.config.ts` to
`tsup.config.bundled_<hash>.mjs` beside it and deletes it when the build
ends. A walk that lists the directory during a concurrent build can name
that file and then fail to read it. `readdirSync` was already guarded;
the per-file `readFileSync` was not.
## Verification
- `cd ui && pnpm exec vitest run` on the three touched files: 3 files,
58 tests passed (under `os-verify-lock`, exit 0).
- **CONTROL**: the importer test still finds exactly
`packages/types/src/zod/index.zod.ts`.
- **Ablations** on the race pin (each restored byte-identical after):
1. ENOENT guard removed (`throw err` unconditionally) → pin red.
2. Name skip removed → pin red (on-disk bundle read as an importer).
3. Guard widened to every error → pin red (`EISDIR` no longer thrown).
- Sweep findings not fixed (read only; none reaches a tsup package root
with an `.mjs` read): `machineLocaleCensus-9909` reads `[cm]?[jt]sx?` at
package roots, but its population (packages depending on
`@object-ui/i18n`) excludes `cli`, `create-plugin`, `data-objectstack`;
`page-node-headings-drawn-11436` walks `examples` only (no tsup there);
`sidebarGroupLabel.callSites-12795` (`tsx?|jsx?|mts`, no `.mjs`);
`product-neutral-renderer.ratchet` lists paths but does not read them;
the rest walk `src/` only or filter to `.ts`/`.tsx`/`.json`.
- `dispatch-gates --commands` (26 commands) run on the final diff: see
`--ran` record below.
<details><summary>dispatch-gates --ran record (26 derived, 26 run, 0
NOT-MEASURED, 0 UNRUN)</summary>
```
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
```
</details>
- Whole-package vitest under `os-verify-lock`: `packages/types/` 387
files / 10,464 tests passed; `packages/app-shell/` 2,176 files passed, 1
skipped (pre-existing) / 19,426 tests passed.
- `eslint` on the three files: exit 0. `tsc -p
ui/packages/types/tsconfig.test.json --noEmit`: exit 0.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; eslint on the touched files passes (full
`pnpm lint` not run locally).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset — this diff is
test-only and publishes nothing (`skip-changeset`); both declaration
lines are filled in above.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to generated references, changelogs or release
notes.
- [x] 8. Title, body and comments are in English (the 维护者速读 block
excepted, per project convention).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufziNut2sBjutK3Sers8
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5a878a3 commit dbf53ef
3 files changed
Lines changed: 108 additions & 12 deletions
File tree
- ui/packages
- app-shell/src
- __tests__
- views/metadata-admin/previews/__tests__
- types/src/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
76 | 86 | | |
77 | 87 | | |
78 | 88 | | |
| |||
148 | 158 | | |
149 | 159 | | |
150 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
151 | 166 | | |
152 | 167 | | |
153 | | - | |
| 168 | + | |
154 | 169 | | |
155 | 170 | | |
156 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
629 | 632 | | |
630 | 633 | | |
631 | | - | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
632 | 643 | | |
633 | 644 | | |
634 | 645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
532 | 533 | | |
533 | 534 | | |
534 | 535 | | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
539 | 564 | | |
540 | 565 | | |
541 | | - | |
542 | 566 | | |
543 | 567 | | |
544 | 568 | | |
545 | 569 | | |
546 | | - | |
| 570 | + | |
547 | 571 | | |
548 | 572 | | |
549 | 573 | | |
550 | 574 | | |
551 | | - | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
552 | 578 | | |
553 | | - | |
| 579 | + | |
554 | 580 | | |
555 | 581 | | |
556 | | - | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
557 | 627 | | |
558 | 628 | | |
559 | 629 | | |
| |||
0 commit comments