diff --git a/src/utils/__tests__/udsMessaging.test.ts b/src/utils/__tests__/udsMessaging.test.ts index f2c8c3ce2..a4c49cee3 100644 --- a/src/utils/__tests__/udsMessaging.test.ts +++ b/src/utils/__tests__/udsMessaging.test.ts @@ -340,7 +340,7 @@ describe('UDS inbox retention', () => { let client: Socket | undefined try { const { connectToPeer } = await import('../udsClient.js') - client = await connectToPeer(path, 50) + client = await connectToPeer(path, 1000) await new Promise(resolve => setTimeout(resolve, 100)) expect(client.destroyed).toBe(false) diff --git a/src/utils/udsClient.ts b/src/utils/udsClient.ts index 45e868c33..1f1a6eee8 100644 --- a/src/utils/udsClient.ts +++ b/src/utils/udsClient.ts @@ -266,7 +266,10 @@ export async function sendToUdsSocket( /** * Connect to a peer and return the raw socket for bidirectional communication. - * The caller is responsible for managing the connection lifecycle. + * The caller is responsible for managing the connection lifecycle, including + * attaching an 'error' listener immediately after the Promise resolves. This + * function detaches its internal error listener on successful connect so + * caller-owned socket errors are not silently swallowed. */ export function connectToPeer( socketPath: string,