From 75c6efd48bcef896e3d0d5073b4f50d998140b2d Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Mon, 10 Aug 2026 20:25:51 -0700 Subject: [PATCH] Remove obsolete pairing connection attempt (#13460) --- .../pairing-connection-attempt.test.ts | 41 --------------- .../transport/pairing-connection-attempt.ts | 50 ------------------- 2 files changed, 91 deletions(-) delete mode 100644 mobile/src/transport/pairing-connection-attempt.test.ts delete mode 100644 mobile/src/transport/pairing-connection-attempt.ts diff --git a/mobile/src/transport/pairing-connection-attempt.test.ts b/mobile/src/transport/pairing-connection-attempt.test.ts deleted file mode 100644 index b05867eb7c0..00000000000 --- a/mobile/src/transport/pairing-connection-attempt.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { afterEach, describe, expect, it, vi } from 'vitest' -import { startPairingConnectionAttempt } from './pairing-connection-attempt' - -describe('pairing connection attempt cleanup', () => { - afterEach(() => { - vi.useRealTimers() - }) - - it('closes the temporary client when the overall pairing timeout fires', () => { - vi.useFakeTimers() - const closeClient = vi.fn() - - const attempt = startPairingConnectionAttempt({ timeoutMs: 25_000, closeClient }) - - expect(attempt.timedOut).toBe(false) - vi.advanceTimersByTime(24_999) - expect(closeClient).not.toHaveBeenCalled() - - vi.advanceTimersByTime(1) - expect(attempt.timedOut).toBe(true) - expect(closeClient).toHaveBeenCalledTimes(1) - - attempt.dispose() - expect(closeClient).toHaveBeenCalledTimes(1) - }) - - it('clears the timeout and closes the temporary client when disposed early', () => { - vi.useFakeTimers() - const closeClient = vi.fn() - - const attempt = startPairingConnectionAttempt({ timeoutMs: 25_000, closeClient }) - attempt.dispose() - - expect(attempt.timedOut).toBe(false) - expect(closeClient).toHaveBeenCalledTimes(1) - - vi.advanceTimersByTime(25_000) - expect(attempt.timedOut).toBe(false) - expect(closeClient).toHaveBeenCalledTimes(1) - }) -}) diff --git a/mobile/src/transport/pairing-connection-attempt.ts b/mobile/src/transport/pairing-connection-attempt.ts deleted file mode 100644 index 0a2d564949a..00000000000 --- a/mobile/src/transport/pairing-connection-attempt.ts +++ /dev/null @@ -1,50 +0,0 @@ -export type PairingConnectionAttempt = { - readonly timedOut: boolean - dispose: () => void -} - -export function startPairingConnectionAttempt({ - timeoutMs, - closeClient -}: { - timeoutMs: number - closeClient: () => void -}): PairingConnectionAttempt { - let disposed = false - let clientClosed = false - let timedOut = false - let timer: ReturnType | null = null - - function closeClientOnce() { - if (clientClosed) { - return - } - clientClosed = true - closeClient() - } - - function dispose() { - if (disposed) { - return - } - disposed = true - if (timer) { - clearTimeout(timer) - timer = null - } - closeClientOnce() - } - - timer = setTimeout(() => { - timer = null - timedOut = true - dispose() - }, timeoutMs) - - return { - get timedOut() { - return timedOut - }, - dispose - } -}