Skip to content

Conversation

@adam-fowler
Copy link
Contributor

@adam-fowler adam-fowler commented Apr 15, 2025

To handle errors fired by previous ChannelHandlers. eg NIOSSLClientHandler

Motivation:

Otherwise if a ChannelHandler previous to the upgrade ChannelHandler fails the error returned is inappropriateOperationForState and the error fired by the original ChannelHandler is lost.

Added testReturnsErrorsFromPriorChannelHandlers. Also had to reorganise setUpClientChannel slightly so I could get the result of the upgrade.

To handle errors fired by previous ChannelHandlers. Otherwise if they fail the error returned is `inappropriateOperationForState` which is not very informative.
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor nit, otherwise this looks really good.

}
}

public func errorCaught(context: ChannelHandlerContext, error: any Error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably fire the error on as well, to avoid breaking any systems that were relying on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Lukasa Lukasa enabled auto-merge (squash) April 16, 2025 12:17
@Lukasa
Copy link
Contributor

Lukasa commented Apr 16, 2025

Looks like we have some test failures here.

auto-merge was automatically disabled April 16, 2025 13:27

Head branch was pushed to by a user without write access

@adam-fowler
Copy link
Contributor Author

Looks like we have some test failures here.

Ah yeah forwarding the error means writeInbound throws an error.

@Lukasa Lukasa enabled auto-merge (squash) April 16, 2025 14:00
@Lukasa Lukasa merged commit d7a8ff6 into apple:main Apr 16, 2025
44 of 45 checks passed
@adam-fowler adam-fowler deleted the websocket-upgrade-errors branch April 16, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants