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

Sendability warnings for ByteToMessage and MessageToBytes Handlers due to changes in addHandlers method. #3056

Closed
flexlixrup opened this issue Jan 14, 2025 · 1 comment

Comments

@flexlixrup
Copy link

Expected behavior

No concurrency warnings in addHandlers method with ByteToMessage and MessageToByte handlers.

Actual behavior

Adding these handlers to a channel pipeline produces warnings.

Steps to reproduce

  1. Compile pulsar-client-swift with NIO 2.77.0
  2. You see no warnings regarding sendability
  3. Compile again with NIO 2.78.0
  4. See the warnings

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

https://github.com/flexlixrup/pulsar-client-swift/blob/1c93824e422ceb9343a632fec2c0258fdc6a5908/Sources/Pulsar/PulsarClient/PulsarClient.swift#L91-L94

In this example you can see where the warnings happens. addHandlers method now requires the PipelineHandlers to be sendable. But these handlers forbid conformance to sendable.

@available(*, unavailable)
extension ByteToMessageHandler: Sendable {}

SwiftNIO version/commit hash

NIO 2.78.0, the issue is due to 1e4fde1

System & version information

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1) Target: arm64-apple-macosx15.0

@Lukasa
Copy link
Contributor

Lukasa commented Jan 14, 2025

This is intentional. The pipeline modification method you’re using actually sends these handlers across concurrency domains, so the concern is warranted. If you’re on the event loop already, which you are in that context, use channel.pipeline.syncOperations.addHandlers, which will not warn.

@Lukasa Lukasa closed this as completed Jan 14, 2025
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

2 participants