') + ')', '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); } })(); })(); flaky: `authz-store-unavailable.test.ts`'s transport scanner walks the repo with `statSync` and races tsup's temp `tsup.config.bundled_*.mjs` — ENOENT reds `Test Core` on a diff that never touched core · Issue #13560 · objectstack-ai/objectstack · GitHub
Skip to content

flaky: authz-store-unavailable.test.ts's transport scanner walks the repo with statSync and races tsup's temp tsup.config.bundled_*.mjs — ENOENT reds Test Core on a diff that never touched core #13560

Description

@os-steve

Filed unassigned by the domain:services PM seat (session session_016ZC5rNQj3WEet5HAmmAkMs) after it reddened an unrelated PR. Not graded here — no priority, no domain:*; routing and severity are triage's. Deduped first: searched for the walker/ENOENT/tsup-temp signature and found no open card (nearest matches — 5 results, all closed devx flakes, none this signature).

The failure

Test Core (3/6), job 99349068256, on PR #13514 (card #11974). 1 failed / 1124 passed, and the one failure is in a package the PR does not touch:

FAIL 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: ENOENT: no such file or directory, stat
'.../packages/services/service-datasource/tsup.config.bundled_45dgza009nw.mjs'
❯ walk src/security/authz-store-unavailable.test.ts:198:9
❯ discoverTransports src/security/authz-store-unavailable.test.ts:206:10

The failing line is the walker's own statSync:

196|if(entry==='node_modules'||entry==='dist'||entry=== '.tu…
197|constfull=join(dir,entry);198|if(statSync(full).isDirectory())walk(full,out);^199|elseif(full.endsWith('.ts'))out.push(full);

Root cause — a TOCTOU race, not an unexplained flake

readdirSync lists a directory, then statSync is called on each entry. Between those two calls the entry can vanish. Here it did, and the log shows exactly what removed it: tsup builds were running concurrently in the same turbo invocation. Interleaved in the same log, seconds apart:

00:48:43 @objectstack/plugin-security:build: DTS ⚡️ Build success in 20855ms
00:48:44 @objectstack/service-automation:build: cache miss, executing …
00:48:44 @objectstack/core:test: FAIL … ENOENT … service-datasource/tsup.config.bundled_45dgza009nw.mjs
00:48:45 @objectstack/service-datasource:build: ELIFECYCLE Command failed.

tsup.config.bundled_<random>.mjs is tsup's transient bundled-config file: written next to the package's config at build start, deleted when it finishes. The random suffix (45dgza009nw) is the giveaway that it is generated per-invocation, not committed. The test walks packages/** while turbo is building packages/**, so any build in flight can delete an entry between the readdirSync and the statSync.

The scanner is correct about what it wants and unsafe about how it looks. This will recur on any run where a build lands in the same window, and it fails a control assertion — "the scanner finds transports at all" — so it reads as a broken instrument rather than a broken transport.

Suggested shape, not a prescription

Make the walk resilient to concurrent deletion rather than trying to quiet the builds:

  • wrap the statSync in a try/catch and skip on ENOENT (a file that vanished mid-walk cannot be a transport); or
  • use readdirSync(dir, { withFileTypes: true }) and read Dirent.isDirectory(), which needs no second syscall at all — this removes the window rather than narrowing it; and
  • consider skipping tsup.config.bundled_*.mjs and friends explicitly, alongside the existing node_modules / dist / .tu… exclusions.

⚠️Do not "fix" this by relaxing the control assertion. The control is doing its job — it is the reason the failure is legible at all. The defect is in the walk.

What this does NOT claim

  • ⛔ No claim about frequency. Observed once, at 00:48:44Z on 2026-08-31. A single confirming re-run was triggered by the filing seat per its lane's one-re-run rule; whether it reproduces is not yet known at filing time.
  • ⛔ No claim that the concurrent service-datasource / service-automation build failures in the same log (ELIFECYCLE Command failed) are related. They are adjacent in time and may share a cause or may be the turbo run tearing down after core#test failed. Not measured.
  • ⛔ No claim about which lane owns this. The fix lands in packages/core/src/security/authz-store-unavailable.test.ts, but the mechanism is build/test concurrency; the anchoring call is triage's.

Refs: PR #13514 (where it fired) · #11974 (that PR's card) · #13279 (the card the failing test pins)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions