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

Don't call mount/3 of LiveView when the instruction of returns of hooks on mount is :halt #1599

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/phoenix_live_view/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,18 @@ defmodule Phoenix.LiveView.Utils do
Calls the `c:Phoenix.LiveView.mount/3` callback, otherwise returns the socket as is.
"""
def maybe_call_live_view_mount!(%Socket{} = socket, view, params, session) do
{_, %Socket{} = socket} = Lifecycle.mount(params, session, socket)
{cont_or_halt, %Socket{} = socket} = Lifecycle.mount(params, session, socket)

if function_exported?(view, :mount, 3) do
:telemetry.span(
[:phoenix, :live_view, :mount],
%{socket: socket, params: params, session: session},
fn ->
socket =
params
|> view.mount(session, socket)
case cont_or_halt do
:cont -> view.mount(params, session, socket)
:halt -> socket
end
|> handle_mount_result!({:mount, 3, view})

{socket, %{socket: socket, params: params, session: session}}
Expand Down