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

retry code is invalid #1790

Closed
pigLoveRabbit520 opened this issue May 18, 2021 · 2 comments
Closed

retry code is invalid #1790

pigLoveRabbit520 opened this issue May 18, 2021 · 2 comments

Comments

@pigLoveRabbit520
Copy link

pigLoveRabbit520 commented May 18, 2021

Problem description

Retry code is not valid:

// Unary RPCs only
var maxRetries = 3;
var interceptor = function(options, nextCall) {
    var savedMetadata;
    var savedSendMessage;
    var savedReceiveMessage;
    var savedMessageNext;
    var requester = {
        start: function(metadata, listener, next) {
            savedMetadata = metadata;
            var newListener = {
                onReceiveMessage: function(message, next) {
                    savedReceiveMessage = message;
                    savedMessageNext = next;
                },
                onReceiveStatus: function(status, next) {
                    var retries = 0;
                    var retry = function(message, metadata) {
                        retries++;
                        var newCall = nextCall(options);
                        newCall.start(metadata, {
                            onReceiveMessage: function(message) {
                                savedReceiveMessage = message;
                            },
                            onReceiveStatus: function(status) {
                                if (status.code !== grpc.status.OK) {
                                    if (retries <= maxRetries) {
                                        retry(message, metadata);
                                    } else {
                                        savedMessageNext(savedReceiveMessage);
                                        next(status);
                                    }
                                } else {
                                    savedMessageNext(savedReceiveMessage);
                                    next({code: grpc.status.OK});
                                }
                            }
                        })
                    };
                    if (status.code !== grpc.status.OK) {
                        retry(savedSendMessage, savedMetadata);
                    } else {
                        savedMessageNext(savedReceiveMessage);
                        next(status);
                    }
                }
            };
            next(metadata, newListener);
        },
        sendMessage: function(message, next) {
            savedSendMessage = message;
            next(message);
        }
    };
    return new InterceptingCall(nextCall(options), requester);
};

code is from doc

Reproduction steps

  1. stop the server
  2. start the client and client will retry
  3. start the server and client will always retry until to max retry times instead of reconnecting to server and getting response.

Environment

  • OS name [Ubuntu 20.04 amd64]
  • Node version [v14.16.1]
  • Package name and version ["@grpc/grpc-js": "^1.3.0"]
@murgatroid99
Copy link
Member

The retry code doesn't control how the client connects to the server. Can you run the client with the environment variables GRPC_TRACE=all and GRPC_VERBOSITY=DEBUG and share the output so that we can see what exactly is happening?

@nicolasnoble
Copy link
Member

This has been more than 4 months without the requested information, closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants