Skip to content

Conversation

gjcairo
Copy link
Collaborator

@gjcairo gjcairo commented Oct 6, 2024

This PR better surfaces transient errors happening deeper in the channel to provide more information to the user.

It depends on grpc/grpc-swift#2083 and grpc/grpc-swift#2084.

@gjcairo gjcairo added the 🆕 semver/minor Adds new public API. label Oct 6, 2024
@gjcairo gjcairo requested a review from glbrntt October 6, 2024 17:54
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Can you split this into two PRs, one for surfacing the errors and one for adding the tests? Makes it easier to review and we get a clearer history.

@gjcairo gjcairo requested a review from glbrntt October 8, 2024 22:37
@gjcairo gjcairo changed the title Add E2E TLS tests and surface channel errors Surface transient channel errors Oct 8, 2024
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

This mostly looks great, left a couple of suggestions on how we can improve it a little more.

@@ -282,16 +282,27 @@ extension Subchannel {
}
}

private func handleConnectFailedEvent(in group: inout DiscardingTaskGroup) {
private func handleConnectFailedEvent(in group: inout DiscardingTaskGroup, error: any Error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than any Error, can we use RPCError and propagate it back to wherever the connectFailed event came from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay I had to do some gymnastics to get this done - not sure if it's compiler errors or I'm misunderstanding something about how Result deals with typed throws, but it wasn't too straightforward 😅

Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

One nit but otherwise looks great!

@@ -127,9 +127,19 @@ package final class Connection: Sendable {
/// This function returns when the connection has closed. You can observe connection events
/// by consuming the ``events`` sequence.
package func run() async {
let connectResult = await Result {
try await self.http2Connector.establishConnection(to: self.address)
func establishConnectionOrThrow() async throws(RPCError) -> HTTP2Connection {
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are the right gymnastics: the other way to do this is to be explicit with the types in the catching: closure:

await Result { () async throws(RPCError) -> HTTP2Connection in
  // ...
}

@gjcairo gjcairo requested a review from glbrntt October 9, 2024 12:59
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Nice one, thanks Gus

@gjcairo gjcairo enabled auto-merge (squash) October 9, 2024 14:50
@gjcairo gjcairo merged commit 350aa4f into grpc:main Oct 9, 2024
4 of 6 checks passed
@gjcairo gjcairo deleted the surface-errors branch October 9, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants