Skip to content

Commit cb2e297

Browse files
GSMLG-BOTclaude
andcommitted
fix: remove dead code and refine init specs in runtime modules
- Remove {:stop, term()} from init/1 specs as implementations never return this tuple in practice - Remove dead error handling code in Bun.handle_continue/2 since start/1 returns port() directly and cannot return {:error, _} - Simplify handle_continue/2 spec to only return {:noreply, state} This eliminates the remaining Dialyzer warnings about unreachable pattern matches and spec mismatches. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 1679ca8 commit cb2e297

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

lib/phoenix/react_server/runtime/bun.ex

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ defmodule Phoenix.ReactServer.Runtime.Bun do
7575

7676
@impl true
7777
@spec init(keyword()) ::
78-
{:ok, Phoenix.ReactServer.Runtime.t(), {:continue, :start_port}} | {:stop, term()}
78+
{:ok, Phoenix.ReactServer.Runtime.t(), {:continue, :start_port}}
7979
def init(component_base: component_base, render_timeout: render_timeout) do
8080
{:ok,
8181
%Phoenix.ReactServer.Runtime{
@@ -89,7 +89,6 @@ defmodule Phoenix.ReactServer.Runtime.Bun do
8989
@impl true
9090
@spec handle_continue(:start_port, Phoenix.ReactServer.Runtime.t()) ::
9191
{:noreply, Phoenix.ReactServer.Runtime.t()}
92-
| {:stop, reason :: term(), Phoenix.ReactServer.Runtime.t()}
9392
def handle_continue(
9493
:start_port,
9594
%Phoenix.ReactServer.Runtime{component_base: component_base} = state
@@ -99,20 +98,15 @@ defmodule Phoenix.ReactServer.Runtime.Bun do
9998
FileWatcher.set_ref(self())
10099
end
101100

102-
case start(component_base: component_base) do
103-
port when is_port(port) ->
104-
Logger.debug(
105-
"Bun.Server started on port: #{inspect(port)} and OS pid: #{get_port_os_pid(port)}"
106-
)
101+
port = start(component_base: component_base)
107102

108-
Server.set_runtime_process(self())
103+
Logger.debug(
104+
"Bun.Server started on port: #{inspect(port)} and OS pid: #{get_port_os_pid(port)}"
105+
)
109106

110-
{:noreply, %Phoenix.ReactServer.Runtime{state | runtime_port: port}}
107+
Server.set_runtime_process(self())
111108

112-
{:error, reason} ->
113-
Logger.error("Failed to start Bun server: #{inspect(reason)}")
114-
{:stop, reason, state}
115-
end
109+
{:noreply, %Phoenix.ReactServer.Runtime{state | runtime_port: port}}
116110
end
117111

118112
@impl true

lib/phoenix/react_server/runtime/deno.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ defmodule Phoenix.ReactServer.Runtime.Deno do
9494

9595
@impl true
9696
@spec init(keyword()) ::
97-
{:ok, Phoenix.ReactServer.Runtime.t(), {:continue, :start_port}} | {:stop, term()}
97+
{:ok, Phoenix.ReactServer.Runtime.t(), {:continue, :start_port}}
9898
def init(component_base: component_base, render_timeout: render_timeout) do
9999
{:ok,
100100
%Phoenix.ReactServer.Runtime{

0 commit comments

Comments
 (0)