') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Issue · GitHub
Skip to content

[finding] authz-store-unavailable.test.ts walks and reads ALL of packages/ twice under the default 5s timeout — it times out as the repo grows, reddening PRs that have nothing to do with authz #13645

Description

@zhuangjianguo

Filed by the domain:engine lane PM. Recording only — no severity asserted, routing is triage's.

⚠️This lane owns the cause. The test was added by #13475 (the #13279 permission-store work), which this seat reviewed and released earlier tonight. Filing it against my own landing.

Measured

CI on PR #13635 went red at 04:44:01Z:

FAIL packages/core/src/security/authz-store-unavailable.test.ts
> [#13279] every transport that authorizes through resolveAuthzContext
> CONTROL: the scanner finds transports at all, and finds THIS repo
Error: Test timed out in 5000ms.
❯ src/security/authz-store-unavailable.test.ts:214:3

Test Files 1 failed | 45 passed (46) · Tests 1 failed | 1134 passed (1135). The shard aborted, so 7 of 8 scheduled packages never ran (check-test-completeness: … 7 never reached — the run stopped before it). One slow test cost the whole shard.

The mechanism — it is a design property, not a flake

packages/core/src/security/authz-store-unavailable.test.ts:

functiondiscoverTransports(): string[]{returnwalk(join(REPO_ROOT,'packages')).filter((f)=>readFileSync(f,'utf8').includes('resolveAuthzContext({'))}
  • It walks the entire packages/ tree and synchronously reads every file into memory.
  • It runs under vitest's default 5000 ms timeout — no per-test override.
  • discoverTransports() is called twice — once in the CONTROL test, once in the SET-EQUALITY test — with no caching. Each call is a complete re-walk and full re-read.

⇒ The cost is O(size of packages/), paid twice, against a fixed budget. Every file added to the monorepo moves it closer to the ceiling, and nothing in the test signals that it is approaching one.

Why it is worth a card rather than a re-run

It reddens PRs that have nothing to do with authorization.#13635 changes packages/objectql, docs and a gate script — it does not touch packages/core at all. It is red because it added files to a tree an unrelated test walks. Any PR that adds files can trip this, and the blame lands on whoever happens to be pushing.

The failure is maximally expensive. It is not one red test — the shard aborts, so seven other packages' suites never run. A single timeout converts into "this shard measured almost nothing".

It gets worse monotonically. There is no threshold anyone will notice crossing; the first symptom is an unrelated PR going red.

Two candidate remedies, neither costed here

  1. Memoise discoverTransports(). It is called twice with identical inputs in the same file — caching halves the cost for one line of change, and is the smallest thing that buys headroom.
  2. Give the scanning tests an explicit timeout proportional to what they actually do, so the budget is a stated decision rather than an inherited default.

The two are complementary; ⛔ I am not prescribing either, and the "raise the timeout" half deserves scrutiny — a bigger number postpones the same failure rather than removing it.

What this does NOT claim

  • ⛔ I did not establish that fix(objectql): cut the tenant-audit control's scope by the object's tenancy, not the caller's flag (#13491) #13635 is the PR that first crossed the line — only that the test's cost scales with a tree that PR adds to, and that the PR does not touch the failing package.
  • ⛔ I could not run the sanctioned single re-run to confirm reproduction: rerun_failed_jobs returned 403 "This workflow is already running" while 16 sibling jobs were still in flight. So "reproduces identically" is UNMEASURED, and this card does not rest on it — it rests on reading the test.
  • ⛔ No claim about how close to 5000 ms the scan currently runs. That would need measuring.

Related

#13475 / #13279 (where this test landed — this lane's own work) · #13635 (the PR it reddened) · #13333 (the standing "derived gate family is not the whole farm" reading)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions