apple / swift-nio-transport-services

Extensions for SwiftNIO to support Apple platforms as first-class citizens.
https://swiftpackageindex.com/apple/swift-nio-transport-services/main/documentation/niotransportservices
Apache License 2.0
282 stars 71 forks source link

Fire the pipelines error caught method when NWConnection's state changes to failed #187

Closed Cartisim closed 10 months ago

Cartisim commented 11 months ago

Fire the pipelines error caught method when NWConnection's state changes to failed

There seems to need to be a method fired when NSConnection's state changes to failed in order to notify other handlers in the pipeline.

Motivation:

When NWConnection fails the connection due to a number of reasons, one being that the clients devices loses internet and we want to receive the failed error in order to handle the applications behavior when the internet is lost. We need to fire the errorCaught method in order to notify handler's in the pipeline.

Modifications:

On line 277 of the file StateManagedNWConnectionChannel.swift I added the line of code to forward the error, namely... self.pipeline.fireErrorCaught(error)

Result:

Our Handlers can now receive the error and handle the socket error state accordingly.

Cartisim commented 11 months ago

Done ✅, Hopefully the test is sufficient. Thanks a bunch!

Cartisim commented 11 months ago

@Lukasa I am happy to do what I can to push this one through. Thanks for your work.

Lukasa commented 10 months ago

Can you bring your branch up-to-date with main?

Cartisim commented 10 months ago

@Lukasa ✅ Thanks again for your hard work!

Lukasa commented 10 months ago

@swift-server-bot test this please