Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIOFileSystem operations thread warnings #2960

Open
fortmarek opened this issue Nov 1, 2024 · 0 comments
Open

NIOFileSystem operations thread warnings #2960

fortmarek opened this issue Nov 1, 2024 · 0 comments

Comments

@fortmarek
Copy link

Expected behavior

Not to see thread warnings when running NIOFileSystem methods in a Task in a SwiftUI app.

Actual behavior

I believe this is very similar to: #2686

That specific issue was fixed by: #2687

In NIOFileSystem, the usage of DispatchSemaphore seems to cause the same issues. I created a reproducible repo that you can check out here: https://github.com/fortmarek/NIOFileSystemThreadWarningReproduction

Note you will need to change the path here to point to an existing file on your local disk. Once you run the app, you will see the following thread warning:
image

Steps to reproduce

  1. Clone the repro repo
  2. Update the path to point to an existing file
  3. Run the macOS app
  4. See the thread warning

If possible, minimal yet complete reproducer code (or URL to code)

import SwiftUI
import NIOFileSystem

public struct ContentView: View {
    public init() {}

    public var body: some View {
        Text("Hello, World!")
            .padding()
            .onAppear() {
                Task {
                    let handle = try await NIOFileSystem.FileSystem.shared.openFile(forReadingAt: .init("/Users/marekfort/Downloads/devices.json"), options: .init())
                    try await handle.close()
                }
            }
    }
}

SwiftNIO version/commit hash

2.76.1

System & version information

nio-diagnose.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant