Skip to content

Commit

Permalink
Avoid ChainSql.Worker fast crash loop
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicletz committed Nov 20, 2023
1 parent 37ff35f commit 6e82329
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/model/chainsql.ex
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,19 @@ defmodule Model.ChainSql do
end

{:ok, db} = Sql.start_database(Db.Default)
{:ok, %Writer{state | db: db}}
{:ok, %Writer{state | db: db}, {:continue, :prepare}}
end

@impl true
def handle_continue(:prepare, state) do
case :ets.whereis(Chain) do
:undefined ->
Process.sleep(1_000)
handle_continue(:prepare, state)

_pid ->
{:noreply, state}
end
end

@impl true
Expand Down

0 comments on commit 6e82329

Please sign in to comment.