Skip to content

Conform HTTPMethod to Sendable - #116

Open
radimvaculik wants to merge 1 commit into
futuredapp:mainfrom
radimvaculik:feature/sendable-http-method
Open

Conform HTTPMethod to Sendable#116
radimvaculik wants to merge 1 commit into
futuredapp:mainfrom
radimvaculik:feature/sendable-http-method

Conversation

@radimvaculik

Copy link
Copy Markdown

Motivation

FTAPIKit 2.0 advertises full Swift 6 concurrency safety, and the async API (URLServer.call(endpoint:)) hands the endpoint to a @concurrent context. Endpoint.method is a stored property on most endpoints, so as soon as a consumer marks its endpoint types Sendable — which the async API effectively requires — the compiler reports:

warning: stored property 'method' of 'Sendable'-conforming struct 'FooEndpoint'
has non-Sendable type 'HTTPMethod'; this is an error in the Swift 6 language mode

The only workaround on the consumer side is a retroactive conformance:

extension HTTPMethod: @retroactive @unchecked Sendable {}

which is awkward and would break the moment FTAPIKit declares the conformance itself.

Change

HTTPMethod is a plain String-backed enum with no associated values, so it is trivially Sendable. This just states it.

Adding a conformance is additive — no existing code breaks.

Not included

Two related gaps I deliberately left out because they need a design decision rather than a one-liner:

  • MultipartBodyPart stores an InputStream, so it is not safely Sendable as-is. Consumers of MultipartEndpoint currently have to fall back to @unchecked Sendable on their endpoint types.
  • Endpoint: Sendable would be the complete fix, since the async API already sends endpoints across isolation domains, but it is source-breaking for existing conformances.

Happy to follow up on either if you have a preferred direction.

Verification

swift build passes. The test suite could not be run to completion here — ErrorHandlingTests and EndpointTypeTests hit httpbin.org over the network and time out in this environment; the failures are unrelated to this change.

@jmarek41
jmarek41 requested a review from ssestak August 15, 2026 17:29
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

Successfully merging this pull request may close these issues.

2 participants