From b423f8a1cf3141d0b15ee899c1c5fe535ff982e9 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Mon, 13 Apr 2026 17:41:34 -0500 Subject: fix: suppress false "network request failed" error on ticket list scroll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When scrolling through a large tracker, SwiftUI's .task modifier cancels in-flight pagination requests as rows leave the screen. URLSession responds with URLError(-999), which was being surfaced to the user as "The network request failed. Please try again." — even though the cancellation is expected and benign. Guard against Task.isCancelled in the catch block so cancellations are silently ignored; isLoadingMore is still reset unconditionally so the next scroll attempt retries from the same cursor position. Fixes: https://todo.sr.ht/~ccleberg/hutch/61 --- Hutch/Views/Tickets/TicketListViewModel.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Hutch/Views/Tickets/TicketListViewModel.swift') diff --git a/Hutch/Views/Tickets/TicketListViewModel.swift b/Hutch/Views/Tickets/TicketListViewModel.swift index 0255798..30e90a7 100644 --- a/Hutch/Views/Tickets/TicketListViewModel.swift +++ b/Hutch/Views/Tickets/TicketListViewModel.swift @@ -341,7 +341,11 @@ final class TicketListViewModel { hasMore = page.cursor != nil reconcileSelectionWithLoadedTickets() } catch { - self.error = error.userFacingMessage + // Ignore cancellation errors — the SwiftUI .task modifier cancels in-flight + // requests when a row scrolls off-screen, which is expected behavior. + if !Task.isCancelled { + self.error = error.userFacingMessage + } } isLoadingMore = false -- cgit v1.2.3