diff --git a/mobile/app/h/[hostId]/index.tsx b/mobile/app/h/[hostId]/index.tsx index 3a2cc2f0659..72373333dd1 100644 --- a/mobile/app/h/[hostId]/index.tsx +++ b/mobile/app/h/[hostId]/index.tsx @@ -499,9 +499,11 @@ export default function HostScreen() { const openWorktreeSession = useCallback( (item: Worktree) => { if (client && connState === 'connected') { - void client.sendRequest('worktree.activate', { - worktree: `id:${item.worktreeId}` - }) + void client + .sendRequest('worktree.activate', { + worktree: `id:${item.worktreeId}` + }) + .catch(() => null) } router.push( `/h/${hostId}/session/${encodeURIComponent(item.worktreeId)}?name=${encodeURIComponent(item.displayName || item.repo)}` @@ -972,9 +974,11 @@ export default function HostScreen() { onPress: () => { if (client) { setSleptIds((prev) => new Set(prev).add(actionTarget.worktreeId)) - void client.sendRequest('worktree.sleep', { - worktree: `id:${actionTarget.worktreeId}` - }) + void client + .sendRequest('worktree.sleep', { + worktree: `id:${actionTarget.worktreeId}` + }) + .catch(() => null) } setActionTarget(null) } diff --git a/mobile/src/transport/rpc-client.ts b/mobile/src/transport/rpc-client.ts index 616791881e2..10b51ab19d2 100644 --- a/mobile/src/transport/rpc-client.ts +++ b/mobile/src/transport/rpc-client.ts @@ -264,9 +264,10 @@ export function connect( } function rejectAllPending(reason: string) { + const error = new Error(reason) for (const [id, req] of pending) { - req.reject(new Error(reason)) pending.delete(id) + queueMicrotask(() => req.reject(error)) } }