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: address unresolved Copilot review feedback from PR #76
Adam Eivy4cb6907f6079
diff --git a/server/lib/fetchWithTimeout.js b/server/lib/fetchWithTimeout.jsindex 053a4e9484..85f4c2877f 100644--- a/server/lib/fetchWithTimeout.js+++ b/server/lib/fetchWithTimeout.js@@ -19,14 +19,19 @@ export async function fetchWithTimeout(url, options = {}, timeoutMs = 15000) {// Fallback: propagate caller abort to our controllerabortHandler = () => controller.abort();options.signal.addEventListener('abort', abortHandler, { once: true });+ if (options.signal.aborted) {+ controller.abort();+ }}}- return fetch(url, { ...options, signal })- .finally(() => {- clearTimeout(timeoutId);- if (options.signal && abortHandler) {- options.signal.removeEventListener('abort', abortHandler);- }- });+ try {+ const response = await fetch(url, { ...options, signal });+ return response;+ } finally {+ clearTimeout(timeoutId);+ if (options.signal && abortHandler) {+ options.signal.removeEventListener('abort', abortHandler);+ }+ }}diff --git a/server/lib/fetchWithTimeout.test.js b/server/lib/fetchWithTimeout.test.jsindex 82f99b301e..bccd2a3e46 100644--- a/server/lib/fetchWithTimeout.test.js+++ b/server/lib/fetchWithTimeout.test.js@@ -4,6 +4,7 @@ import { fetchWithTimeout } from './fetchWithTimeout.js';describe('fetchWithTimeout', () => {beforeEach(() => {vi.restoreAllMocks();+ vi.unstubAllGlobals();});it('passes through successful fetch', async () => {@@ -17,17 +18,20 @@ describe('fetchWithTimeout', () => {it('aborts after timeout', async () => {vi.useFakeTimers();- vi.stubGlobal('fetch', vi.fn().mockImplementation((_url, opts) =>- new Promise((_resolve, reject) => {- opts.signal.addEventListener('abort', () => reject(new DOMException('aborted', 'AbortError')));- })- ));+ try {+ vi.stubGlobal('fetch', vi.fn().mockImplementation((_url, opts) =>+ new Promise((_resolve, reject) => {+ opts.signal.addEventListener('abort', () => reject(new DOMException('aborted', 'AbortError')));+ })+ ));- const promise = fetchWithTimeout('http://example.com', {}, 100);- vi.advanceTimersByTime(100);+ const promise = fetchWithTimeout('http://example.com', {}, 100);+ vi.advanceTimersByTime(100);- await expect(promise).rejects.toThrow('aborted');- vi.useRealTimers();+ await expect(promise).rejects.toThrow('aborted');+ } finally {+ vi.useRealTimers();+ }});it('clears timeout on success', async () => {diff --git a/server/services/cosRunnerClient.js b/server/services/cosRunnerClient.jsindex 1b93dab85e..19a454be4e 100644--- a/server/services/cosRunnerClient.js+++ b/server/services/cosRunnerClient.js@@ -128,11 +128,7 @@ export async function spawnAgentViaRunner(options) {claudePath} = options;- // Create abort controller for timeout (60 seconds for agent spawn)- const controller = new AbortController();- const timeoutId = setTimeout(() => controller.abort(), 60000);-- const response = await fetch(`${COS_RUNNER_URL}/spawn`, {+ const response = await fetchWithTimeout(`${COS_RUNNER_URL}/spawn`, {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({@@ -146,8 +142,7 @@ export async function spawnAgentViaRunner(options) {cliArgs,claudePath}),- signal: controller.signal- }).finally(() => clearTimeout(timeoutId));+ }, 60000);if (!response.ok) {const error = await response.json();@@ -250,10 +245,7 @@ export async function executeCliRunViaRunner(options) {timeout} = options;- const controller = new AbortController();- const timeoutId = setTimeout(() => controller.abort(), 60000);-- const response = await fetch(`${COS_RUNNER_URL}/run`, {+ const response = await fetchWithTimeout(`${COS_RUNNER_URL}/run`, {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({@@ -265,8 +257,7 @@ export async function executeCliRunViaRunner(options) {envVars,timeout}),- signal: controller.signal- }).finally(() => clearTimeout(timeoutId));+ }, 60000);if (!response.ok) {const error = await response.json();