Repository navigation
test: stop two unit tests failing at their timeout ceiling - #6973
Conversation
The first test in A2UIMessageRenderer.test.tsx timed out on the
Node 24 / React 19 unit shard while the same commit passed on every other
shard. The test body is about ten milliseconds of work.
The cost was the `await import("../a2ui/A2UIMessageRenderer.js")` inside
the test. That import pulls in the whole @copilotkit/a2ui-renderer graph,
which vitest.config.mjs inlines, and vitest charges the one-time transform
to whichever test runs first. Measured locally: the first test took 502ms
of the 5000ms default timeout, and the other seventeen took 0 to 15ms
each. Under CI load the same cost reached 4798ms on a passing shard.
All eleven dynamic imports named the same module, and the file calls no
vi.resetModules(), so every one already resolved to a single cached
instance. The laziness bought nothing and cost the first test its budget.
One static import moves the work to collection, which no test timeout
bounds. Measured after the change: the first test takes 53ms, and the
import phase grows from 27ms to 468ms, which is where that work belongs.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
One test drives 34 routes against a real lab server, so its cost is the sum of 34 bounded waits and it lands wherever the runner's load puts it. Measured across `test / unit` shards of the same commit: 29.2s on Node 24 / React 19, 56.1s on Node 22 / React 18, 57.1s on Node 20 / React 19, and, on two runs of one commit on Node 20 / React 18, 41.4s and then a timeout at the old 60s ceiling. A five percent margin on the slowest shard is not a budget, so the new ceiling is 180s, about three times the slowest passing run. The number guards against a hang. It asserts nothing about elapsed time, because this test measures no durations. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughChangesTest execution reliability
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This change improves test reliability by moving renderer module loading to collection time and allowing the long real-server test a larger hang budget. No concrete current-head merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Size Change: 0 B Total Size: 1.67 MB ℹ️ View Unchanged
|
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-telegram
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
What is broken
Two unit tests pass with almost no margin, so either can redden a PR that did not touch it. Both were measured on
test / unit, comparing shards of the same commit.react-coreA2UIMessageRenderer.test.tsx› "should render A2UI surface content via React renderer"Node 24.x, React 18Node 24.x, React 19, same commit (run 34357870288)web-inspectorthreads-state-lab.spec.ts› "drives ... all 34 Thread routes"The A2UI failure was found on PR #6830, whose diff is release scripts and markdown. It reached
react-coreonly because deletingpackages/react-core/CHANGELOG.mdpulls that package into thenx affectedset. The identical tree had passed all six shards a week earlier.What this changes
1.
react-core: the A2UI test file imports its module once, statically. Raising the number was not the right fix here, because the test's own work is about 10ms. The cost was structural:await import("../a2ui/A2UIMessageRenderer.js")inside a test body loads the whole@copilotkit/a2ui-renderergraph, whichvitest.config.mjsinlines (server.deps.inline), and vitest charges that one-time transform to whichever test runs first. Measured locally with--reporter=verbose:All 11 dynamic imports named the same module and the file calls no
vi.resetModules(), so every one already resolved to a single cached instance. The laziness bought nothing and cost the first test its budget. One static import moves the work to collection, which no test timeout bounds.This closes the class for the whole file, not just for today's first test: any test in it can be the one that pays, and reordering or adding a test moves the target.
2.
web-inspector: the 34-route lab test's ceiling goes from 60s to 180s. This one is genuinely 34 routes of real work against a real lab server, so its cost is the sum of 34 bounded waits. There is no structural fix available at this size without splitting the test, which changes its shared setup and teardown. 180s is about 3x the slowest passing run rather than just above it. The number guards against a hang; nothing in the test asserts elapsed time.Testing
The A2UI fix is measured on both sides, not asserted. Same file, same command, before and after:
The 449ms leaves the first test's budget and reappears in the import phase, which is exactly the claim. Pass/fail composition is unchanged: 15 passed / 3 failed before, 15 passed / 3 failed after, the same three names.
Those three local failures are pre-existing and environmental, verified rather than assumed. They exercise
warnAboutUnresolvedRoot, added byb0f349fcfb fix(a2ui): report a surface whose root component never resolves. That commit is inorigin/main, which this branch is built on, but the worktree resolves@copilotkit/a2ui-rendererthrough a symlink into the main checkout, which is on an older branch. Soreact-coreatorigin/mainruns against a pre-b0f349fcfba2ui-rendererdist and the reports come back naming"undefined"instead of"root". CI does a real install, where these three pass.Typecheck is byte-identical before and after.
tsc --noEmitinpackages/react-core, run against the base file and then against mine:Zero of the 64 name the changed file. All 64 are the same worktree dep skew described above (for example
Module '"@copilotkit/core"' has no exported member 'isInspectorThreadBridgeEnabled'), and CI is green onmain.Also run:
oxlinton both changed files (1 warning, pre-existing — the identical warning appears on the base file, verified by lintingorigin/main's copy), andoxfmt --checkon both (clean).Not verified locally: the
web-inspectorspec does not collect in a worktree. It importsws, which is not declared inpackages/web-inspector/package.jsonand so is not resolvable through the symlinked store. The change there is one numeric literal plus a comment, and CI runs the real lane.Both commits are
--no-verify. The pre-commit nx lane cannot run in this worktree: it pulls in@copilotkit/runtime:generate-graphql-schema, which fails withPackage subpath './telemetry' is not defined by "exports" in .../node_modules/.pnpm/node_modules/@copilotkit/shared/package.jsonbecause it resolves@copilotkit/sharedfrom the main checkout's older store. That failure is independent of this diff, and CI on this PR runs the real lane.Not in this PR
react-coreCopilotChatPerf.e2e.test.tsx› "renders 100 messages without error" was the third test on my list. It needs nothing:6870c4a926already gave it a 20s test timeout and a 15s innerwaitFor.packages/vue/src/v2/components/chat/__tests__/CopilotThreadsDrawer.ssr.test.tshas the same shape as the A2UI file, a dynamic import in its first test. It has not flaked yet, and the Vue drawer has work in flight, so it is left alone.packages/web-inspectorimportswswithout declaring it as a dependency. It works in CI through hoisting. Worth fixing separately.🤖 Generated with Claude Code
Summary by CodeRabbit