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

[#184] gracefully handles server process shutdown #375

Conversation

beligante
Copy link
Contributor

Fixes #184

Add pattern match to handle server process shutdown. It's very common to see these error happen when we manually setup gRPC server in our test cases. ExUnit gracefully shutdown the applications (for example), thus causing the server processes to exit with :shutdown reason.

Without this handler, a lot of error logs are produced, causing to misleading logs.

@beligante beligante force-pushed the gracefully-handle-server-process-shutdown branch from dc02197 to 5883c4a Compare July 1, 2024 22:07
@sleipnir sleipnir merged commit ca57719 into elixir-grpc:master Jul 2, 2024
8 checks passed
@beligante beligante deleted the gracefully-handle-server-process-shutdown branch July 2, 2024 16:15
@@ -7,6 +7,12 @@ defmodule GRPC.Integration.ServerTest do
def get_feature(point, _stream) do
%Routeguide.Feature{location: point, name: "#{point.latitude},#{point.longitude}"}
end

def route_chat(_ex_stream, stream) do
GRPC.Server.send_headers(stream, %{})
Copy link

@zhihuizhang17 zhihuizhang17 Jul 22, 2024

Choose a reason for hiding this comment

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

Hi, I'm investigating a Cowboy shutdown issue for my gRPC service running version v0.9.0 in production. My client receives {:error, %GRPC.RPCError{status: 13, message: "status got is 204 instead of 200"}} when Cowboy shuts down.

In my unit test, if I add this line GRPC.Server.send_headers(stream, %{}), my client receives {:error, %GRPC.RPCError{status: 13, message: ":stream_error: {:stream_error, :no_error, :\"Stream reset by server.\"}"}}.

How can I gracefully handle the service's endpoint shutdown from the client side? Should I send headers like retry or goaway to prompt the client to retry?

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.

The GRPC.Adapter.Cowboy.Handler does not handle :EXIT message
3 participants