Skip to content

Commit

Permalink
Trap exits rather than unlink
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Feb 29, 2024
1 parent 2ed4b6e commit e66beb6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 1 addition & 4 deletions test/phoenix_live_view/integrations/assign_async_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule Phoenix.LiveView.AssignAsyncTest do
@endpoint Endpoint

setup do
Process.flag(:trap_exit, true)
{:ok, conn: Plug.Test.init_test_session(Phoenix.ConnTest.build_conn(), %{})}
end

Expand Down Expand Up @@ -51,7 +52,6 @@ defmodule Phoenix.LiveView.AssignAsyncTest do

test "lv exit brings down asyncs", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/assign_async?test=lv_exit")
Process.unlink(lv.pid)
lv_ref = Process.monitor(lv.pid)
async_ref = Process.monitor(Process.whereis(:lv_exit))
send(lv.pid, :boom)
Expand All @@ -62,7 +62,6 @@ defmodule Phoenix.LiveView.AssignAsyncTest do

test "cancel_async", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/assign_async?test=cancel")
Process.unlink(lv.pid)
async_ref = Process.monitor(Process.whereis(:cancel))
send(lv.pid, :cancel)

Expand Down Expand Up @@ -155,7 +154,6 @@ defmodule Phoenix.LiveView.AssignAsyncTest do

test "lv exit brings down asyncs", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/assign_async?test=lc_lv_exit")
Process.unlink(lv.pid)
lv_ref = Process.monitor(lv.pid)
async_ref = Process.monitor(Process.whereis(:lc_exit))
send(lv.pid, :boom)
Expand All @@ -166,7 +164,6 @@ defmodule Phoenix.LiveView.AssignAsyncTest do

test "cancel_async", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/assign_async?test=lc_cancel")
Process.unlink(lv.pid)
async_ref = Process.monitor(Process.whereis(:lc_cancel))

Phoenix.LiveView.send_update(lv.pid, Phoenix.LiveViewTest.AssignAsyncLive.LC,
Expand Down
4 changes: 1 addition & 3 deletions test/phoenix_live_view/integrations/start_async_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule Phoenix.LiveView.StartAsyncTest do
@endpoint Endpoint

setup do
Process.flag(:trap_exit, true)
{:ok, conn: Plug.Test.init_test_session(Phoenix.ConnTest.build_conn(), %{})}
end

Expand All @@ -34,7 +35,6 @@ defmodule Phoenix.LiveView.StartAsyncTest do

test "lv exit brings down asyncs", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/start_async?test=lv_exit")
Process.unlink(lv.pid)
lv_ref = Process.monitor(lv.pid)
async_ref = Process.monitor(Process.whereis(:start_async_exit))
send(lv.pid, :boom)
Expand All @@ -45,7 +45,6 @@ defmodule Phoenix.LiveView.StartAsyncTest do

test "cancel_async", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/start_async?test=cancel")
Process.unlink(lv.pid)
async_ref = Process.monitor(Process.whereis(:start_async_cancel))

assert render(lv) =~ "result: :loading"
Expand Down Expand Up @@ -136,7 +135,6 @@ defmodule Phoenix.LiveView.StartAsyncTest do

test "cancel_async", %{conn: conn} do
{:ok, lv, _html} = live(conn, "/start_async?test=lc_cancel")
Process.unlink(lv.pid)
async_ref = Process.monitor(Process.whereis(:start_async_cancel))

Phoenix.LiveView.send_update(lv.pid, Phoenix.LiveViewTest.StartAsyncLive.LC,
Expand Down

0 comments on commit e66beb6

Please sign in to comment.