@@ -230,11 +230,16 @@ final class ParseableClient: Sendable {
230 func createStream(name: String) async throws {
230 func createStream(name: String) async throws {
231 let encoded = try Self.encodePathComponent(name)
231 let encoded = try Self.encodePathComponent(name)
232 _ = try await performRequest(method: "PUT", path: "/api/v1/logstream/\(encoded)")
232 _ = 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()
235 func deleteStream(name: String) async throws {
238 func deleteStream(name: String) async throws {
236 let encoded = try Self.encodePathComponent(name)
239 let encoded = try Self.encodePathComponent(name)
237 _ = try await performRequest(method: "DELETE", path: "/api/v1/logstream/\(encoded)")
240 _ = 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()
240 func getStreamSchema(stream: String) async throws -> StreamSchema {
245 func getStreamSchema(stream: String) async throws -> StreamSchema {
@@ -343,6 +348,12 @@ final class ParseableClient: Sendable {
344 return config
349 return config
345 } catch let newEndpointError {
350 } 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
347 return try await legacyAlerts()
358 return try await legacyAlerts()
348 } catch {
359 } catch {