git.iko.soy/parseable-macos
on master help sign in
Fix 3 bugs: stale sort task, cache invalidation after stream ops, and auth fallback
commit3eb694c37aff0078ecb7884e0a52a9a01d2fac43 authoriko <mail@iko.soy> dateSun 21 Jun 2026, 00:22 (3 months ago) parent7f50526
2 files changed+16−1
ParseableViewer/Services/ParseableClient.swift+11 ParseableViewer/Views/LiveTailView.swift+5−1
ParseableViewer/Services/ParseableClient.swift+11
@@ -230,11 +230,16 @@ final class ParseableClient: Sendable {
230230 func createStream(name: String) async throws {
231231 let encoded = try Self.encodePathComponent(name)
232232 _ = try await performRequest(method: "PUT", path: "/api/v1/logstream/\(encoded)")
233+ // Recreating a same-named stream must not serve a previous stream's
234+ // cached schema/stats/info (cached for 60s), so drop the cache.
235+ await cache.invalidate()
233236 }
234237
235238 func deleteStream(name: String) async throws {
236239 let encoded = try Self.encodePathComponent(name)
237240 _ = try await performRequest(method: "DELETE", path: "/api/v1/logstream/\(encoded)")
241+ // Invalidate so a later same-named stream doesn't see stale schema/stats/info.
242+ await cache.invalidate()
238243 }
239244
240245 func getStreamSchema(stream: String) async throws -> StreamSchema {
@@ -343,6 +348,12 @@ final class ParseableClient: Sendable {
343348 }
344349 return config
345350 } catch let newEndpointError {
351+ // An auth failure won't be fixed by hitting the legacy endpoint (it
352+ // would just 401 again), so surface it immediately rather than
353+ // delaying the re-auth prompt behind a second failing round-trip.
354+ if case ParseableError.unauthorized = newEndpointError {
355+ throw newEndpointError
356+ }
346357 do {
347358 return try await legacyAlerts()
348359 } catch {
ParseableViewer/Views/LiveTailView.swift+5−1
@@ -306,13 +306,17 @@ struct LiveTailView: View {
306306 entries.map { ($0.id, extractSeverity(from: $0.record, severityColumns: sevCols)) },
307307 uniquingKeysWith: { first, _ in first }
308308 )
309+ // Cancel any pending sort task before either path: when the sort is
310+ // cleared (guard below), a previously-scheduled task could otherwise
311+ // wake after its 150ms delay and overwrite the unsorted result with
312+ // stale sorted entries.
313+ liveTailSortTask?.cancel()
309314 guard let col = sortColumn else {
310315 cachedSorted = entries
311316 severityColumnSet = sevCols
312317 severityByID = severityMap
313318 return
314319 }
315− liveTailSortTask?.cancel()
316320 let asc = sortAscending
317321 liveTailSortTask = Task {
318322 try? await Task.sleep(for: .milliseconds(150))