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
fix(tests): preserve watcher failures preceding caller cancellation (#13314)
[._.]/ Adam Eivyb7e14d810b7f
diff --git a/scripts/lib/vitestTempRootFixture.js b/scripts/lib/vitestTempRootFixture.jsindex 0442a02ea0..773919a89f 100644--- a/scripts/lib/vitestTempRootFixture.js+++ b/scripts/lib/vitestTempRootFixture.js@@ -222,7 +222,8 @@ export function runFixtureToCompletion({ args, options }, ceilingMs = FIXTURE_RU* killed watcher to close. FIXTURE_CLOSE_UNCONFIRMED means retain the host.*/export async function runWatchConfigRestart(host, workspace, inspect, { signal } = {}) {- if (signal?.aborted) throw fixtureAborted(signal);+ const callerCancellation = () => Object.assign(fixtureAborted(signal, 'watch fixture cancelled by caller'), { code: 'FIXTURE_CALLER_CANCELLED' });+ if (signal?.aborted) throw callerCancellation();const marks = join(host, 'marks');mkdirSync(marks);const { args, options } = createVitestTempFixture(host, workspace, `@@ -262,7 +263,7 @@ export async function runWatchConfigRestart(host, workspace, inspect, { signal }let output = '';child.stdout.on('data', (chunk) => { output += chunk; });child.stderr.on('data', (chunk) => { output += chunk; });- const onAbort = () => abort.abort(signal.reason);+ const onAbort = () => abort.abort(callerCancellation());signal?.addEventListener('abort', onAbort, { once: true });if (signal?.aborted) onAbort();const timer = setTimeout(() => abort.abort(new Error('watch fixture readiness timed out')), WATCH_READY_MS);@@ -292,7 +293,11 @@ export async function runWatchConfigRestart(host, workspace, inspect, { signal }}return await inspect({ first, restarted, pid: child.pid });} catch (error) {- failure = spawnError ?? error;+ // Readiness wraps this controller's reason in AbortError. Recover that+ // exact reason so a later caller cancellation cannot relabel an earlier+ // timeout or premature exit as an expected cancellation.+ failure = spawnError ?? (error.name === 'AbortError' && error.cause === abort.signal.reason+ ? abort.signal.reason : error);failure.message += `\n${output}`;throw failure;} finally {diff --git a/scripts/lib/vitestWatchFixtureSettlement.test.js b/scripts/lib/vitestWatchFixtureSettlement.test.jsindex cd2e45dddf..5ed4fd1c07 100644--- a/scripts/lib/vitestWatchFixtureSettlement.test.js+++ b/scripts/lib/vitestWatchFixtureSettlement.test.js@@ -65,6 +65,21 @@ describe('watch fixture process settlement', () => {await expect(result).resolves.toMatchObject({ name: 'AbortError' });});+ it('preserves premature exit when caller cancellation arrives during settlement', async () => {+ const child = fixture({ ready: false });+ const controller = new AbortController();+ const pending = runWatchConfigRestart(host, 'server', () => {}, { signal: controller.signal });+ const result = pending.catch(error => error);+ child.emit('exit', 1, null);+ await tick();+ controller.abort();+ child.emit('close', 1, null);+ const error = await result;+ expect(error.message).toContain('watch fixture exited before readiness');+ expect(error.code).not.toBe('FIXTURE_CALLER_CANCELLED');+ expect(error.name).toBe('Error');+ });+it('keeps a nested run close watchdog failure distinct from confirmed cancellation', async () => {fixture({ ready: false });vi.useFakeTimers();diff --git a/scripts/vitestTempRoot.test.js b/scripts/vitestTempRoot.test.jsindex 58f37e674a..4c44737ed7 100644--- a/scripts/vitestTempRoot.test.js+++ b/scripts/vitestTempRoot.test.js@@ -138,7 +138,7 @@ describe('real workspace runner temp lifecycle', () => {} catch (error) {if (error.code === 'FIXTURE_CLOSE_UNCONFIRMED') cleanupConfirmed = false;// Cancellation is expected, but failed process settlement is still fatal.- if (!signal.aborted || error.name !== 'AbortError') throw error;+ if (error.code !== 'FIXTURE_CALLER_CANCELLED') throw error;} finally {if (cleanupConfirmed) rmSync(host, { recursive: true, force: true });}