Skip to content

Commit

Permalink
Add graceful exit contract to transports (#2107)
Browse files Browse the repository at this point in the history
ref: phoenixframework/phoenix_pubsub#68

Previously a channel could gracefully terminate
using the stop semantics of a regular genserver;
however when restarting an application for deploys
the shutdown of the transport and channel processes
would be indistinguisable from an intentional channel
shutdown and would cause clients to incorrectly not
reconnect after server restart. This commit adds a
{:graceful_exit, channel_pid, %Phoenix.Socket.Message{}}
contract to distinguish an intentional channel exit from
what should be regarded as an error condition on the client.
  • Loading branch information
chrismccord authored Feb 21, 2017
1 parent 44e1679 commit f5ac3e8
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions test/phoenix/transports/transport_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ defmodule Phoenix.Transports.TransportTest do
## on_exit_message

test "on_exit_message/3" do
assert Transport.on_exit_message("foo", "1", :normal) ==
%Message{ref: "1", event: "phx_close", payload: %{}, topic: "foo"}
assert Transport.on_exit_message("foo", "1", :shutdown) ==
%Message{ref: "1", event: "phx_close", payload: %{}, topic: "foo"}
assert Transport.on_exit_message("foo", "1", {:shutdown, :whatever}) ==
%Message{ref: "1", event: "phx_close", payload: %{}, topic: "foo"}
assert Transport.on_exit_message("foo", "1", :oops) ==
%Message{ref: "1", event: "phx_error", payload: %{}, topic: "foo"}
end
Expand Down

0 comments on commit f5ac3e8

Please sign in to comment.