Skip to content

Commit d3b16ae

Browse files
author
unraid
committed
fix: use a deadline timer for peer connects
The raw socket handoff no longer needs Socket#setTimeout; an ordinary connection deadline keeps the timeout behavior while avoiding an internal socket timeout listener that has no reliable UDS integration path to exercise. Constraint: Keep Codecov coverage honest without adding ignore pragmas, mocks, or fallback suppression. Rejected: c8 ignore on the timeout listener | hides the uncovered branch instead of simplifying the lifecycle. Rejected: keep Socket#setTimeout listener | leaves a socket listener lifecycle to manage for a connect-only deadline. Confidence: high Scope-risk: narrow Directive: Keep connectToPeer errors caller-owned via onSocketError and reject pre-connect failures with UdsPeerConnectionError. Tested: bun test src/utils/__tests__/udsMessaging.test.ts src/services/AgentSummary/__tests__/agentSummary.test.ts Tested: bunx tsc --noEmit --pretty false Tested: bun run lint Tested: bun test src/utils/__tests__/udsMessaging.test.ts --coverage --coverage-reporter lcov --coverage-dir coverage-uds Tested: bun run test:all Tested: bun test --coverage --coverage-reporter lcov --coverage-dir coverage Tested: bun run build Tested: bun run build:vite Tested: bun audit Not-tested: Manual external ACP peer runtime beyond repository tests.
1 parent a90c164 commit d3b16ae

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/utils/__tests__/udsMessaging.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ describe('UDS inbox retention', () => {
354354

355355
expect(client.destroyed).toBe(false)
356356
expect(client.listenerCount('error')).toBe(1)
357-
expect(client.listenerCount('timeout')).toBe(0)
358357

359358
const socketError = new Error('post-connect failure')
360359
client.emit('error', socketError)

src/utils/udsClient.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,14 @@ export function connectToPeer(
280280
return new Promise<Socket>((resolve, reject) => {
281281
const conn = createConnection(socketPath)
282282
let settled = false
283-
const onTimeout = () => {
284-
fail(new Error('Connection timed out'))
285-
}
283+
const timeout = setTimeout(
284+
fail,
285+
timeoutMs,
286+
new Error('Connection timed out'),
287+
)
286288
function cleanupListeners(): void {
287-
conn.setTimeout(0)
289+
clearTimeout(timeout)
288290
conn.off('error', fail)
289-
conn.off('timeout', onTimeout)
290291
}
291292
function fail(cause: unknown): void {
292293
if (settled) {
@@ -307,8 +308,6 @@ export function connectToPeer(
307308
resolve(conn)
308309
})
309310
conn.on('error', fail)
310-
conn.once('timeout', onTimeout)
311-
conn.setTimeout(timeoutMs)
312311
})
313312
}
314313

0 commit comments

Comments
 (0)