From 788253b2342c95d43d4dec9a661d3ea21ac0bbd3 Mon Sep 17 00:00:00 2001 From: Dmitry Kovba Date: Wed, 3 Sep 2025 13:28:00 -0700 Subject: [PATCH] Use `detachUnsafeFileDescriptor()` as suggested by the error message to prevent a leak detection crash when `close()` fails. --- .../ContainerizationOCI/Client/RegistryClient+Fetch.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/ContainerizationOCI/Client/RegistryClient+Fetch.swift b/Sources/ContainerizationOCI/Client/RegistryClient+Fetch.swift index 286c42cc0..488ed237c 100644 --- a/Sources/ContainerizationOCI/Client/RegistryClient+Fetch.swift +++ b/Sources/ContainerizationOCI/Client/RegistryClient+Fetch.swift @@ -195,7 +195,12 @@ extension RegistryClient { try await writer.flush() try await handle.close() } catch { - try? await handle.close() + do { + try await handle.close() + } catch { + // Use `detachUnsafeFileDescriptor()` as suggested by the error message to prevent a leak detection crash when `close()` fails. + _ = try handle.detachUnsafeFileDescriptor() + } throw error } let computedDigest = hasher.finalize()