gleam-lang / otp

📫 Fault tolerant multicore programs with actors
https://hexdocs.pm/gleam_otp/
Apache License 2.0
458 stars 53 forks source link

`handle_exit` called with missing `starter` causes a crash #67

Open tomalexhughes opened 4 months ago

tomalexhughes commented 4 months ago

Creating an issue for this problem discussed in the Discord.

It's possible for the handle_exit function in the supervisor module to be called with state that is missing the starter.exec function.

This causes the following error due to this let assert

Runtime terminating during boot ({#{function=><<"handle_exit">>,line=>303,message=><<"Assertion pattern match failed">>,module=><<"gleam/otp/supervisor">>,value=>none,gleam_error=>let_assert},[{'gleam@otp@supervisor',handle_exit,2,[{file,"/[....]/build/dev/erlang/gleam_otp/_gleam_artefacts/gleam@otp@supervisor.erl"},{line,235}]},{'gleam@otp@actor',loop,1,[{file,"/[....]/build/dev/erlang/gleam_otp/_gleam_artefacts/gleam@otp@actor.erl"},{line,150}]}]})

Unfortunately I do not have a way to reproduce at the moment and I'm unsure as to the exact details that cause the none value.

lpil commented 4 months ago

Thank you.

ghivert commented 4 months ago

FYI, I have a regular error on Gloogle due to this error, because I'm exiting normally some children. That triggers server to restart. It's not a big deal at the moment, but it's bothering enough I'd like to fix it. Are you interested in some PR @lpil ? In case you are, do you have some opinions or some hints to get started on the subject?

lpil commented 3 months ago

PRs welcome but I've not investigated this.

ghivert commented 3 days ago

I think I understood why it's happening: I'm using a supervisor to start fire & forget tasks. In Gloogle, when I want to extract signatures, I'm spawning a process to do it in an async way, but I'm starting it within a supervisor. So when it shutdown, there's no other children to start, because it's supposed to stop. Am I right to say that every supervisor children processes should be thought as long running processes, that restart automatically?