test(a2ui-toolkit): de-flake deep child-chain cycle tests#1949
Merged
Conversation
The two deep-chain cycle tests in validate.test.ts intermittently tripped vitest's 5000ms default timeout on CI (~5358ms), reddening the unit workflow's typescript job repo-wide. Root cause is not the validator: validateA2UIComponents on the 50k chain runs in ~59ms (build 6ms + validate 53ms). findChildCycles is already a linear, Set/Map-backed iterative DFS — no quadratic scan to fix. The flake is GC/scheduling jitter: each test allocates ~150k objects (50k components + 50k DFS frames + path/adjacency), and two such tests under parallel-fork contention on a 2-vCPU runner stall on GC, inflating wall-clock far past CPU time. Fix (test-only — validator left untouched, it is optimal): - N 50000 -> 20000 in both deep tests. V8's recursive overflow depth is ~8807 (trivial frame; lower for a real DFS frame), so 20k is still >2x past it and proves the walk is iterative, while cutting allocations 2.5x to shrink the GC-stall window. - Add an explicit 30000ms timeout to decouple the provably-fast assertion from CI runner scheduling jitter. Toolkit suite: 84/84 pass, validate.test.ts ~103ms.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Python Preview PackagesVersion
Install with uvAdd the TestPyPI index to your [[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
explicit = trueThen install the packages you need: # Core SDK
uv add 'ag-ui-protocol==0.0.0.dev1781285184' --index testpypi
# Integrations (each already depends on the matching ag-ui-protocol preview)
uv add 'ag-ui-langgraph==0.0.0.dev1781285184' --index testpypi
uv add 'ag-ui-crewai==0.0.0.dev1781285184' --index testpypi
# NOTE: ag-ui-agent-spec depends on pyagentspec (git-only, not on PyPI).
# You will need to install pyagentspec separately from its git repo.
uv add 'ag-ui-agent-spec==0.0.0.dev1781285184' --index testpypi
uv add 'ag_ui_adk==0.0.0.dev1781285184' --index testpypi
uv add 'ag_ui_strands==0.0.0.dev1781285184' --index testpypiInstall with pippip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
ag-ui-protocol==0.0.0.dev1781285184
Commit: 074df4d |
@ag-ui/a2a-middleware
@ag-ui/a2ui-middleware
@ag-ui/event-throttle-middleware
@ag-ui/mcp-apps-middleware
@ag-ui/mcp-middleware
@ag-ui/a2a
@ag-ui/adk
@ag-ui/ag2
@ag-ui/agno
@ag-ui/aws-strands
@ag-ui/claude-agent-sdk
@ag-ui/crewai
@ag-ui/langchain
@ag-ui/langgraph
@ag-ui/llamaindex
@ag-ui/mastra
@ag-ui/pydantic-ai
@ag-ui/vercel-ai-sdk
@ag-ui/watsonx
@ag-ui/a2ui-toolkit
create-ag-ui-app
@ag-ui/client
@ag-ui/core
@ag-ui/encoder
@ag-ui/proto
commit: |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The two deep-chain cycle tests in
sdks/typescript/packages/a2ui-toolkit/src/__tests__/validate.test.tsintermittently trip vitest's 5000ms default timeout on CI (measured ~5358ms), reddening theunitworkflow'stypescriptjob repo-wide. Unrelated to any open PR — puremain-branch CI hygiene.Introduced by
ddb4184d(@contextablemark, #1944 child-cycle work).Diagnosis
The validator is not quadratic. Profiled
validateA2UIComponentson the exact 50k chain: ~59ms (build 6ms + validate 53ms).findChildCyclesis already a linear,Set/Map-backed iterative DFS — no.includes()scan, no per-node re-lookup, no recursion to overflow. Nothing to optimize.The flake is GC/scheduling jitter, not CPU. Each test allocates ~150k objects (50k components + 50k DFS frames + path/adjacency arrays). Two such tests under vitest's parallel-fork pool on a 2-vCPU runner stall on GC, inflating wall-clock far past the ~59ms of actual CPU work. Bigger N = more allocations = more stall susceptibility.
Fix (test-only — validator left untouched, it is optimal)
Changing the validator would be a fake fix. Instead, in both deep-chain tests:
Verification
cd sdks/typescript/packages/a2ui-toolkit && pnpm test→ 84/84 pass,validate.test.ts~103ms total (both deep tests included), comfortably under timeout.No product behavior change. cc @contextablemark — touches your #1944 cycle-check tests.