SwiftPackageIndex / SwiftPackageIndex-Server

The Swift Package Index is the place to find Swift packages!
https://swiftpackageindex.com
Apache License 2.0
538 stars 42 forks source link

Fix s6 warnings #3306

Closed finestructure closed 3 weeks ago

finestructure commented 3 weeks ago

This fixes all remaining Swift6 warnings (and one deprecation warning related to LogHandler).

The warnings were of the kind Converting non-sendable function value and raised for our request handers:

        app.get(SiteURL.package(.key, .key, .none).pathComponents,
                use: PackageController.show).excludeFromOpenAPI()

A known fix for this was to write

        app.get(SiteURL.package(.key, .key, .none).pathComponents,
                use: { try await PackageController.show(req: $0) }).excludeFromOpenAPI()

which is quite a bit of extra noise. We were hoping the compiler should infer @Sendable automatically to make this change unnecessary.

However, a simpler fix is to annotate the request handlers as @Sendable. See also https://forums.swift.org/t/vapor-and-sendable-route-handlers/71613/3

This clears all the noise now and should get us warning free.