Skip to content

Commit

Permalink
Do not leak 1012 to longpoll
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Jun 15, 2023
1 parent 89ae241 commit a6aa8cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/phoenix/socket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,12 @@ defmodule Phoenix.Socket do
{:stop, {:shutdown, :disconnected}, state}
end

def __info__(:socket_drain, state) do
{:stop, {:shutdown, :draining}, {1012, 'restart'}, state}
def __info__(:socket_drain, {_state, socket} = state) do
# TODO handle {:stop, :draining} reason inside websock_adapter and convert to 1012 there
case socket.transport do
:websocket -> {:stop, {:shutdown, :draining}, {1012, 'restart'}, state}
_ -> {:stop, {:shutdown, :draining}, state}
end
end

def __info__({:socket_push, opcode, payload}, state) do
Expand Down
4 changes: 0 additions & 4 deletions lib/phoenix/transports/long_poll_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ defmodule Phoenix.Transports.LongPoll.Server do
state = %{state | handler: {handler, handler_state}}
{:noreply, state}

{:stop, reason, {_close_code, _msg}, handler_state} ->
state = %{state | handler: {handler, handler_state}}
{:stop, reason, state}

{:stop, reason, handler_state} ->
state = %{state | handler: {handler, handler_state}}
{:stop, reason, state}
Expand Down

0 comments on commit a6aa8cb

Please # to comment.