Flow exiting with normal reason
TylerPachal opened this issue · comments
Tyler Pachal commented
I am trying to supervise my Flow, and restart it if something goes wrong. In my supervisor init/1
I have something like this:
children = [
worker(MyStreamer, [], restart: :transient)
]
MyStreamer
has a start_link
function that just creates the Flow
then starts it:
def start_link(_) do
flow = make_flow()
Flow.start_link(flow)
end
The problem is that my supervisor is not restarting my flow when a runtime exception occurs, because the exit messages have :normal
reasons like this:
{:EXIT, #PID<0.195.0>, :normal}
I was able to reproduce it by running this example in iex which raises a runtime error but has a normal exit reason:
Process.flag(:trap_exit, true)
flow = [3,2,1,0,-1,-2,-3] |> Flow.from_enumerable() |> Flow.map(&(10/&1))
Flow.start_link(flow)
flush()
I am expecting to see a non-normal exit reason like when doing this in iex:
Process.flag(:trap_exit, true)
spawn_link(fn -> 10/0 end)
flush()
José Valim commented
Can you provide a sample project or a single file that I can run with “mix
run foo.exs”? That will make it much easier to reproduce the issue. Thanks!
--
*José Valimwww.plataformatec.com.br
<http://www.plataformatec.com.br/>Founder and Director of R&D*
Tyler Pachal commented
I put together a small gist here. The code is simply:
## foo.exs
import IEx.Helpers
Process.flag(:trap_exit, true)
[3,2,1,0,-1,-2,-3]
|> Flow.from_enumerable()
|> Flow.map(&(10/&1)) # Generate a runtime error
|> Flow.start_link()
flush()
Thanks!