go-grpc-middleware icon indicating copy to clipboard operation
go-grpc-middleware copied to clipboard

`grpc_retry.StreamClientInterceptor` does not pass the correct `"x-retry-attempty"` metadata value

Open slnt opened this issue 3 years ago • 2 comments

In retry.go in the implementation of StreamClientInterceptor there is the following code:

for attempt := uint(0); attempt < callOpts.max; attempt++ {
if err := waitRetryBackoff(attempt, parentCtx, callOpts); err != nil {
	return nil, err
}
callCtx := perCallContext(parentCtx, callOpts, 0)

This code should be (unless I'm missing some reason for it not to):

for attempt := uint(0); attempt < callOpts.max; attempt++ {
if err := waitRetryBackoff(attempt, parentCtx, callOpts); err != nil {
	return nil, err
}
callCtx := perCallContext(parentCtx, callOpts, attempt)

Also, there seems to be an extraneous y character in the definition of AttemptMetadataKey:

const (
	AttemptMetadataKey = "x-retry-attempty"
)

slnt avatar Feb 15 '22 18:02 slnt

Hi, thanks for the issue. It appears at least the AttemptMetadataKey typo is also present in v2, though the major issue here does appear to be addressed: https://github.com/grpc-ecosystem/go-grpc-middleware/blob/a5b9e0b0458cc2e39faab057564de9efe962f0ba/interceptors/retry/retry.go#L30-L70.

johanbrandhorst avatar Feb 18 '22 02:02 johanbrandhorst

Typo fixed in https://github.com/grpc-ecosystem/go-grpc-middleware/pull/543

bwplotka avatar Mar 19 '23 01:03 bwplotka