Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to connectrpc.com/connect v1.14.0 and google.golang.org/protobuf v1.32.0 #111

Merged
merged 7 commits into from
Jan 30, 2024

Conversation

nicksnyder
Copy link
Member

No description provided.

@nicksnyder nicksnyder changed the title Update to connectrpc.com/connect v1.14.0 and google.golang.org/protobuf v1.31.0 Update to connectrpc.com/connect v1.14.0 and google.golang.org/protobuf v1.32.0 Dec 26, 2023
@nicksnyder
Copy link
Member Author

@emcfarlane tests are failing, can you take a look?

For GET request Content-Type is not required and is now rejected by connect.
With the new Send operation a bytes.Buffer will use the WriteTo method
to write the response body. On a zero length payload Write will not be
called. Make the body handling more robust by calling Write(nil) to
trigger a body write.
Fallback to allow context cancel errors if the server errors.
@emcfarlane
Copy link
Collaborator

@nicksnyder working. 3 different failure cases that I've corrected, left details in the commits. Will need review.

@nicksnyder
Copy link
Member Author

Thanks! Will let @jhump review the substantive changes when he is back

@@ -1249,6 +1249,7 @@ func (w *responseWriter) close() {
w.WriteHeader(http.StatusOK)
}
if w.w != nil {
_, _ = w.w.Write(nil) // trigger any final writes
Copy link
Member

Choose a reason for hiding this comment

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

@emcfarlane, this makes me a little nervous. This smells like we inadvertently introduced a backwards-incompatible change in connect-go. Maybe you can elaborate a little on "the new Send operation", and why this change was really needed, and why that's not a bug in connect-go?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep sure. The bytes.Buffer WriteTo won't Write to the io.Writer if the payload size is zero: https://cs.opensource.google/go/go/+/refs/tags/go1.21.5:src/bytes/buffer.go;l=260

Vanguard-go uses the Write to trigger the conversion of an empty protomessage (valid zero length payload) to a json message ({}). I do think this is an issue with how vanguard-go triggers conversions. It shouldn't be dependant on the write mechanism. This was the minimal change I could see to fix the issue but I would presume we wish to revisit later.

}
}
default:
} else if serverInvoked {
Copy link
Member

Choose a reason for hiding this comment

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

Why all of these changes? The description on the individual commits don't really provide context. Was this necessary to fix something that changed in connect-go? We've actually relaxed the semantics now and allow a cancellation error on the server for all circumstances, when it was previously gated on expectServerCancel. That doesn't seem right.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep this changed as context error was being set. I thought it was related to connectrpc/connect-go#643 but might have been too hastily in removing it for all cases. Here are the relevant test logs:

            --- FAIL: TestTranscoder_BufferTooLargeFails/transforming_writer/must_buffer_response_stream/per_svc_options (0.00s)
                vanguard_test.go:387: WrapStreamingHandler TestTranscoder_BufferTooLargeFails/transforming_writer/must_buffer_response_stream/per_svc_options
                transcoder_test.go:534: RPC error: resource_exhausted: max buffer size (1024) exceeded
                transcoder_test.go:534:
                        Error Trace:    /Users/edward/src/github.com/connectrpc/vanguard-go/vanguard_test.go:932
                                                                /Users/edward/src/github.com/connectrpc/vanguard-go/transcoder_test.go:534
                        Error:          Not equal:
                                        expected: 0x8
                                        actual  : 0x1
                        Test:           TestTranscoder_BufferTooLargeFails/transforming_writer/must_buffer_response_stream/per_svc_options
                transcoder_test.go:534: resource_exhausted: buffer limit exceeded
                transcoder_test.go:534: canceled: context canceled
            --- FAIL: TestTranscoder_BufferTooLargeFails/transforming_writer/must_buffer_response_stream/default_svc_opts (0.00s)
                vanguard_test.go:387: WrapStreamingHandler TestTranscoder_BufferTooLargeFails/transforming_writer/must_buffer_response_stream/default_svc_opts
                transcoder_test.go:534: RPC error: resource_exhausted: max buffer size (1024) exceeded
                transcoder_test.go:534:
                        Error Trace:    /Users/edward/src/github.com/connectrpc/vanguard-go/vanguard_test.go:932
                                                                /Users/edward/src/github.com/connectrpc/vanguard-go/transcoder_test.go:534
                        Error:          Not equal:
                                        expected: 0x8
                                        actual  : 0x1
                        Test:           TestTranscoder_BufferTooLargeFails/transforming_writer/must_buffer_response_stream/default_svc_opts

I've pushed up a change to add back expectServerCancel. Adding it to the out message passes this test. Does that look correct? It does look like the error should be a resource error though.

@emcfarlane emcfarlane requested a review from jhump January 25, 2024 14:07
@emcfarlane emcfarlane enabled auto-merge (squash) January 30, 2024 19:42
@emcfarlane emcfarlane merged commit 5432aa4 into main Jan 30, 2024
5 checks passed
@emcfarlane emcfarlane deleted the upgrade-connect branch January 30, 2024 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants