Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: bound the sharing fail-fast cleanup subprocess by its lifecycle, not a 20s clock (#13121)
Adam Eivy40de2fca4da1
diff --git a/scripts/sharingRoundtripCleanup.test.js b/scripts/sharingRoundtripCleanup.test.jsindex 79a3c2c812..19400d8416 100644--- a/scripts/sharingRoundtripCleanup.test.js+++ b/scripts/sharingRoundtripCleanup.test.js@@ -1,22 +1,32 @@-import { expect, it } from 'vitest';-import { spawnSync } from 'node:child_process';-import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { afterAll, expect, it as vitestIt } from 'vitest';+import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';-import { createVitestTempFixture, fixtureReadyFailureSource } from './lib/vitestTempRootFixture.js';+import { ownTestBodies } from '../server/lib/mockPathsDataRoot.js';+import { createVitestTempFixture, fixtureReadyFailureSource, runFixtureToCompletion } from './lib/vitestTempRootFixture.js';++// The nested run's own ceiling; the outer budget adds headroom so it is never tighter.+const RUN_CEILING_MS = 120000;++// A fail-fast failure in another file cancels this body while it awaits the nested+// run; own it so teardown waits for its `finally` to remove the host (#12924).+const owned = ownTestBodies(vitestIt);+const it = owned.it;+afterAll(() => owned.drain());// A sibling fails only once an actual export reaches its first bucket write.// The cancelled body must finish its original round-trip assertions before// teardown removes its bucket; otherwise atomicWrite recreates that bucket.-it('settles sharing round-trip writes before fail-fast fixture cleanup', () => {+it('settles sharing round-trip writes before fail-fast fixture cleanup', async ({ signal }) => {const host = mkdtempSync(join(tmpdir(), 'sharing-cancel-'));try {const fixture = join(host, 'fixture');const ready = join(fixture, 'ready');const events = join(fixture, 'events');const finished = join(fixture, 'finished');- const { args, options } = createVitestTempFixture(host, 'server', '');+ const fixtureRun = createVitestTempFixture(host, 'server', '');+ const { args } = fixtureRun;const sourcePath = fileURLToPath(new URL('../server/services/sharing/integration.test.js', import.meta.url));const header = "it('exports a series, processes the manifest as inbox, then promotes — id + origin preserved', async () => {";const end = "expect(await importer.listInbox(bucket.id)).toEqual([]);";@@ -68,15 +78,20 @@ it('settles sharing round-trip writes before fail-fast fixture cleanup', () => {writeFileSync(join(fixture, 'failure.test.js'), fixtureReadyFailureSource(ready));args[args.indexOf('--maxWorkers') + 1] = '2';args.push('--bail=1', '--testNamePattern', 'exports a series, processes the manifest|controlled sibling failure');- const result = spawnSync(process.execPath, args, options);- const output = `${result.stdout}\n${result.stderr}`;- expect(result.error).toBeUndefined();+ // The nested run is bounded by its lifecycle, not a short fixed clock: a cold+ // import graph under full-suite load can outlast a 20s spawnSync deadline, which+ // reported ETIMEDOUT with no phase. Phase files are named in any failure.+ const result = await runFixtureToCompletion(fixtureRun, RUN_CEILING_MS, { signal });+ if (signal.aborted) return;+ const phases = ['ready', 'finished'].map(name => `${name}=${existsSync(join(fixture, name))}`).join(' ');+ const output = `${result.stdout}\n${result.stderr}\nlifecycle phases: ${phases}`;+ expect(result.error, output).toBeUndefined();expect(result.status, output).toBe(1);expect(output).toContain('controlled sibling failure');- const observed = readFileSync(events, 'utf8');+ const observed = existsSync(events) ? readFileSync(events, 'utf8') : '';expect(observed, output).toBe('export-write-ready\nbucket-at-resume:true\nbucket-after-write:true\nround-trip-assertions-complete\nbody-settled\n');expect(output).not.toMatch(/ENOTEMPTY|ENOENT|Unhandled|test temp leak:/);} finally {rmSync(host, { recursive: true, force: true });}-}, 25000);+}, RUN_CEILING_MS + 15000);