erlangpl
erlangpl copied to clipboard
Make supervision tree fetching more error proof
If a child is wrongly specified as supervisor
, but it does not
implement this behaviour, the supervisor:which_children/0
call can
return unpredictable values. (Especially if the worker is a gen_server
which can return any sort of funny value in its handle_call
).
This issue has been seen in more than one open-source library.
Hopefully closes #37
So if some branch of sup-tree is not OTP correct for example it would skip whole branch?
I think in most cases a worker
child is incorrectly declared as a supervisor
child so there are no grandchildren and it is safe to handle this process as a leaf.
If this process is a custom parent which has children but does not implement the which_children
api then, yes, the subtree under it would be ignored. But in this case epl would have a hard time to figure out grandchildren anyway.
(I only know of rabbitmq which has its own supervisor implementation, but it also supports the which_children
call)
We want to enforce correct OTP structure so rather throw error than ignore something incorrect.
/ cc @michalslaski
Or instead of throwing an error we could show an information in the UI that this branch of the tree cannot be resolved.
It makes total sense not to hide the discrepancy. The easiest way would be to just crash with a very descriptive error message. But it would be more user-friendly to either print an error message (only once and not every second when the sup-tree is updated) or indicate this in the UI somehow. If it is not just a crash I would like to leave the implementation to you guys.