You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
withConnectedSocket(_:channelInitializer:) should create a channel and activate its handlers.
Actual behavior
withConnectedSocket(_:channelInitializer:) does not activate handlers of the channel it created, and further operations on it don't work.
Steps to reproduce
letfd=connectToSomewhere()Task{do{letchannel=tryawait bootstrap.withConnectedSocket(fd){ channel in
channel.pipeline.addHandler(EchoHandler()).flatMap{ _ inreturn channel.eventLoop.makeSucceededFuture(channel)}}tryawait channel.closeFuture.get()}catch{// ...}}
The code above will produce an error operationUnsupported.
SwiftNIO version/commit hash
2.75.0
System & version information
This issue is irrelevant to the operating system.
Possible reason
withConnectedSocket(_:channelInitializer:) will internally invoke withConnectedSocket(eventLoop:socket:channelInitializer:postRegisterTransformation:) method and it then invokes initializeAndRegisterChannel(channel:channelInitializer:registration:postRegisterTransformation:) method. The type of registration parameter is @escaping @Sendable (Channel) -> EventLoopFuture<Void>, which will take an any Channel as a parameter. The implementation closure is at
The real registerAlreadyConfigured0(promise:) implementation from SocketChannel is not called, however, the default implementation from Channel extension is called:
Expected behavior
withConnectedSocket(_:channelInitializer:)
should create a channel and activate its handlers.Actual behavior
withConnectedSocket(_:channelInitializer:)
does not activate handlers of the channel it created, and further operations on it don't work.Steps to reproduce
The code above will produce an error
operationUnsupported
.SwiftNIO version/commit hash
2.75.0
System & version information
This issue is irrelevant to the operating system.
Possible reason
withConnectedSocket(_:channelInitializer:)
will internally invokewithConnectedSocket(eventLoop:socket:channelInitializer:postRegisterTransformation:)
method and it then invokesinitializeAndRegisterChannel(channel:channelInitializer:registration:postRegisterTransformation:)
method. The type ofregistration
parameter is@escaping @Sendable (Channel) -> EventLoopFuture<Void>
, which will take anany Channel
as a parameter. The implementation closure is atswift-nio/Sources/NIOPosix/Bootstrap.swift
Line 1364 in ff98c93
The real
registerAlreadyConfigured0(promise:)
implementation fromSocketChannel
is not called, however, the default implementation fromChannel
extension is called:swift-nio/Sources/NIOCore/Channel.swift
Line 205 in ff98c93
This is an known issue of Swift: swiftlang/swift#42725
The text was updated successfully, but these errors were encountered: