Skip to content

Conversation

@gjcairo
Copy link
Collaborator

@gjcairo gjcairo commented Mar 27, 2024

We're not currently handling write promises correctly in the server and client stream handlers.

This PR adds proper handling by storing promises linked to each write, and chaining them when they're framed together in a single frame, which can be passed onto the context/write call on flush().

@gjcairo gjcairo marked this pull request as ready for review March 27, 2024 09:41
@gjcairo gjcairo requested a review from glbrntt March 27, 2024 09:41
/// A message is ready to be sent.
case sendMessage(ByteBuffer)
case sendMessage(
message: ByteBuffer,
Copy link
Collaborator

Choose a reason for hiding this comment

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

at this point it's no longer a message, it could be multiple framed messages (though I realise now that all of the naming here is message based...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, you're right. I've renamed these to be more consistent although I did keep awaitMoreMessages and noMoreMessages, since I believe it's not wrong to refer to messages in those situations (as we're either waiting for more messages to arrive, regardless of how we frame them, or we know that no more messages will arrive).


@testable import GRPCHTTP2Core

final class GRPCMessageFramerTests: XCTestCase {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add some tests which check that promises are cascaded as expected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a test checking this to the GRPCStreamStateMachine tests, but I also just added (or rather modified an existing one) in the framer tests.

@glbrntt glbrntt added the version/v2 Relates to v2 label Mar 27, 2024
@gjcairo gjcairo requested a review from glbrntt March 27, 2024 14:11
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.

Couple of places where we've incorrectly stopped failing a promise but otherwise looks good!

@gjcairo gjcairo requested a review from glbrntt March 27, 2024 14:53
@gjcairo gjcairo merged commit 97994e1 into grpc:main Mar 27, 2024
@gjcairo gjcairo deleted the state-machine-promises branch March 27, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

version/v2 Relates to v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants