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

Make sure net/api/client.Subscribe loop ends gracefully when client is closing #515

Open
merlinran opened this issue May 14, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@merlinran
Copy link
Contributor

When client.Close is called, the gRPC connection gets closed, and the stream.Recv() call here returns a gRPC internal error ErrConnClosing, which is not considered a grace close, hence causes a log.Fatalf().

2021/05/14 13:07:05 error in subscription stream: rpc error: code = Unavailable desc = transport is closing

resp, err := stream.Recv()
if err == io.EOF {
return
}
if err != nil {
stat := status.Convert(err)
if stat.Code() != codes.Canceled {
log.Fatalf("error in subscription stream: %v", err)
}
return
}

This shouldn't be considered a fatal error, but maybe more importantly, provide a way to signal the loop to return immediately?

@merlinran merlinran added the bug Something isn't working label May 14, 2021
@sanderpick
Copy link
Member

could we check errors.Is(err, ErrConnClosing) and just bail when true?

@merlinran
Copy link
Contributor Author

Nope, ErrConnClosing is defined in an internal package so we don't have access. Didn't check if the error wrapper can be recognizable though. Anyway it should be low priority since it only happens when closing down.

@sanderpick
Copy link
Member

Cool, I thought that since it was capitalized it was exported. Anyway, sgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants