-
Notifications
You must be signed in to change notification settings - Fork 3.4k
DynamicSupervisor: the option "max_restarts" only work if provided as initial argument #13675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
For clarity, Can you please link to the documentation that implied max_restarts work on start_link/3? Thank you! |
@josevalim, I think it comes from @spec start_link([option() | init_option()]) :: Supervisor.on_start() where |
But that’s start_link/1, right? |
You're right. I mis-read it 😄 Maybe the OP did too 🤷 😄 Sorry for the noise. |
Well, it's not so much a bug or a bad doc, but more like it's easy to confuse First and foremost, the people from https://github.com/arjan/singleton has suffered the same confusion (in fact, that's how I got -after 2 weeks- to nail this 😄 ), if you look at https://github.com/arjan/singleton/blob/master/lib/singleton/supervisor.ex#L25 and https://github.com/arjan/singleton/blob/master/lib/singleton/supervisor.ex#L25, you'll see that they intend to use I've tried to read about it in the docs, and I find it at least slightly misleading...
So, in a nutshell, I can't exactly "blame" the doc, but I think it's very easy to get confused and assume |
Hi @JoeZ99! No worries, we can totally blame the docs! They can always improve and that's the biggest question: how could we improve them? Would you like to try a PR? I would be glad to review it. |
hey @josevalim , txs!!! I've made a PR: #13678, but I don't know what else to do ... Another thing is that this "doc improvement" is to be read at least since version 1.15.4 of elixir, I don't know if I should make a PR for that tag and every subsequent one ... |
what does "OP" mean 😄 ???? |
I believe it means "Original Poster", so it was referring to you. :) |
Elixir and Erlang/OTP versions
elixir 15.4
otp 26
Operating system
linux
Current behavior
When specifying the "max_restarts" option as a regular when using
DynamicSupervisor
, it doesn't work.How to check?
Have this two modules:
and
an then on a shell, do:
and you'll see how it explodes only three times (because after 3 restarts, the dynamicsupervisor dies), in spite of you specifying "100" restarts in the options
however, if you do:
you'll see it restarts the children more than three times.
Expected behavior
Based on documentation, I expect that providing
max_restarts
as regular option:would work
But only work if provided as initial option:
The text was updated successfully, but these errors were encountered: