Skip to content

Commit 4653515

Browse files
committed
fetch if not cached
1 parent 38d7765 commit 4653515

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/live_debugger/gen_servers/state_server.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ defmodule LiveDebugger.GenServers.StateServer do
1919

2020
@doc """
2121
Returns previously stored state of the LiveView channel process identified by `pid`.
22-
If the state is not found, it returns `{:error, :not_found}`.
22+
If the state is not found, it fetches it from the process.
23+
If the process is dead, it returns an error.
2324
"""
2425
@spec get(pid :: pid()) :: {:ok, CommonTypes.channel_state()} | {:error, term()}
2526
def get(pid) when is_pid(pid) do
@@ -109,8 +110,11 @@ defmodule LiveDebugger.GenServers.StateServer do
109110

110111
def get(pid) do
111112
case :ets.lookup(@server_module.ets_table_name(), @server_module.record_id(pid)) do
112-
[{_, channel_state}] -> {:ok, channel_state}
113-
[] -> {:error, :not_found}
113+
[{_, channel_state}] ->
114+
{:ok, channel_state}
115+
116+
[] ->
117+
ProcessService.state(pid)
114118
end
115119
end
116120
end

0 commit comments

Comments
 (0)