Skip to content

Question: should IMAPClientHandler be Sendable? #824

@odrobnik

Description

@odrobnik

Hi, we ran into Swift concurrency warnings when using IMAPClientHandler with SwiftNIO async pipeline APIs from tests in SwiftMail.

The pattern is:

try await channel.pipeline.addHandler(IMAPClientHandler())

ChannelPipeline.addHandler requires ChannelHandler & Sendable, but IMAPClientHandler is not currently declared Sendable, so the compiler warns that IMAPClientHandler does not conform to Sendable. For now we are using a test-target workaround:

@preconcurrency import NIOIMAP

extension IMAPClientHandler: @retroactive @unchecked Sendable {}

That works for our event-loop-confined usage, but it would be nicer not to need a downstream retroactive conformance. How would the maintainers prefer this to be addressed?

Options that came to mind:

  • mark IMAPClientHandler as @unchecked Sendable upstream, matching NIO event-loop confinement expectations
  • provide a recommended wrapper or factory for async pipeline installation
  • use another model if the handler should not be treated as Sendable, possibly actor-based or otherwise isolated

Happy to open a PR if there is an intended direction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions