This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
test(plugin-timeline): remove the shared-lastItems race in the colorField ladder - #7527
Merged
Merged
Conversation
…ield ladder `colorsFor` left every render mounted and waited on `lastItems.length` alone. Both halves were needed for the failure: RTL's auto-cleanup runs in `afterEach`, never between two renders inside one `it`, so an `it` calling `colorsFor` twice had two `ObjectTimeline`s alive writing one module-level `lastItems` — and a length-only predicate cannot say which of them wrote it. The late write is structural, not incidental: `ObjectTimeline`'s data effect lists `objectDef` in its deps, and `objectDef` is set by a separate metadata fetch, so every mount issues two `find()` calls. The second is still in flight when the predicate goes green, so each `colorsFor` returned with a write still queued against a component nothing ever unmounted. Under load that write landed after the next call had reset `lastItems`, and rung 2 read the previous rung's colour back out — kicking whatever PR happened to be in the merge queue. - `colorsFor` now unmounts its own render in a `finally`, so there is never a second writer. - The predicate identifies the AUTHOR: each call stamps a token on `titleField` and waits for `lastItems` to carry that token, so "this render is ready" is distinguishable from "something else wrote again". - A structural guard asserts no renderer is alive before each mount. It is a synchronous DOM fact, not a timing window: on the pre-fix file it reads 1 on the second call of every multi-render `it`, deterministically. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EMrWaQw3XS5DxTHxp4yRyC
… nothing Empty frontmatter: the diff is one test file plus this changeset, so no package contract moves. `check-changeset-presence.mjs` treats that as the explicit exemption rather than a missing declaration. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EMrWaQw3XS5DxTHxp4yRyC
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
os-project-manager
marked this pull request as ready for review
September 3, 2026 17:30
os-project-manager
deleted the
claude/issue-7521-colorfieldladder-race
branch
September 3, 2026 17:57
This was referenced Sep 5, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #7521
This was not a flake. It kicked whatever PR happened to be in the merge queue under load, so every queue failure had to rule it out first.
Causal chain, re-derived here (agrees with the card, and names the engine it did not)
The card's reading is confirmed:
lastItemsis module-level, thevi.mockrenderer writes it on every render,colorsFornever unmounts, and thewaitForpredicate readlastItems.lengthonly — so it could not tell which of two live components had written it.What the card did not name is why a late write is guaranteed rather than incidental.
ObjectTimelinehas two async effects, and the data effect listsobjectDefin its dependency array while a separate metadata fetch setsobjectDef. So every mount issues twofind()calls, and the second is still in flight when the predicate goes green. Measured trace of onecolorsFor:Every
colorsFortherefore returned with a write queued against a component nothing ever unmounted. A gated repro then forced the interleaving and reproduced the CI failure exactly — the stale component re-rendering after the next call's reset:The deterministic probe
Asserting "two renderers are alive after two
colorsForcalls" (the card's suggested shape) is not reliably red: in the very run where the bug bites, the length-only predicate resolves on the stale component's write before the new one has painted, so only one element is in the DOM. Measured — the failing cell of the matrix below reportsalive=1.The probe used instead inverts it and asserts, before each mount, that no renderer is alive:
This is timing-independent. At the top of the second
colorsForin anyit, the first component's element is in the DOM as a settled fact: it rendered (the previouswaitForcould only have been satisfied by it), and RTL's auto-cleanup runs inafterEach, never between two renders inside oneit. Pre-fix reading, necessarily red on exactly the two multi-renderits:The two fixes, and what each is actually worth
colorsFortears its own render down in afinally, so there is never a second writer.titleFieldand waits forlastItemsto carry it. The token is deliberately not the value under test, so the predicate can separate "this render is ready" from "something else wrote again" without asserting the colour the caller is about to assert.A 2x2 ablation on a deterministic race gate measures what each buys. Reported as measured, which is not what the card assumed:
["#abc"]["#123456"]["#123456"]["#123456"]So each fix alone closes the correctness hole in the measured scenario — the card's "neither alone is enough" does not hold as stated, and I am not going to claim a red I did not get. They are still both worth keeping, for different reasons: the unmount removes the second writer (
alive2 to 1), the predicate refuses a stale write while two components coexist, and the structural probe pins the unmount mechanically. The first control I built for this matrix did not light up — its gap was too short and the new component overwrote the stale one beforewaitFor's first poll — so it was repaired until the pre-fix cell failed, rather than read as "no bug".Per-
itcensus (all seven, not just the two named)colorsForcallsitThe fix is in the shared helper, so all seven are covered, not only the two that could fail today. No test was skipped, disabled, retried or split into separate
its, and noObjectTimelineproduct code was touched.Verification
At final HEAD
4e69c05f5:pnpm exec vitest run packages/plugin-timeline/—Test Files 22 passed (22),Tests 287 passed (287), exit 0.tsc -p tsconfig.test.json --noEmit— exit 0, after building the dependency closure (pnpm --filter "@object-ui/plugin-timeline^..." build). The edited file is proven in that program via--listFiles(1 hit), so this is a real reading and not a vacuous one.node scripts/check-changeset-presence.mjsandcheck-changeset-no-major.mjs— both exit 0.no-explicit-any.Both readings were taken at
e1331a952; the only later commit adds.changeset/7521-timeline-colorfieldladder-race.mdand moves 0 non-.changesetpaths, so they hold at4e69c05f5.Repo-wide
pnpm lintis left to CI. The narrowing above is a measurement rather than a skip: eslint is not type-aware in this repo (noprojectService, noparserOptions.project), so this diff cannot move the verdict on any file it does not touch.Changeset
Empty frontmatter — the established spelling here (239 existing changesets use it). One test file plus the changeset; no package contract moves, so this declares "releasing nothing" rather than a version bump. No
skip-changesetlabel: nothing in this repo reads it.Same-shape census (task 4 — reported, deliberately not fixed here)
Scanned all 2451 tracked test files for the shape: module-level
let+ written inside avi.mockfactory + anitrendering more than once + nounmount()/cleanup().The single step-(c) file is this one. The scanner was validated against the pre-fix version of this file as a positive control and lit up correctly, so the zero is a reading rather than a query-shape artifact. Nothing else in the repo carries this shape, so there is no follow-up issue to file.
🤖 Generated with Claude Code
https://claude.ai/code/session_01EMrWaQw3XS5DxTHxp4yRyC
Generated by Claude Code