Skip to content
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

Keys of already started components for ::component/component-function-threw-exception #72

Open
lgrapenthin opened this issue Apr 9, 2022 · 2 comments

Comments

@lgrapenthin
Copy link

::component/component-function-threw-exception error is useful in that it provides the partially started system, the failed component and its key as well. It would be useful to also have a list of keys of components that have already been started.

My usecase is to stop all those components again before doing a fix and retrying.
Without knowing which components have been started already, the only workaround I found is to calculate the start order like component does internally and take-while until the key has been reached.

@stuartsierra
Copy link
Collaborator

Hi @lgrapenthin, thanks for your comment!

I generally recommend that component stop functions be safe to call even on a component that has not been started. That way you can just call stop on the system map attached to the exception to stop any components that were started.

Alternatively, each component could track if it has been started by associng a key in its start method.

Your suggestion is still an interesting alternative. It would require update-system to keep track of which keys it had started. I'm not sure if that's worth the extra complexity, given that there are other alternatives and a partially-started system is always an exceptional case. But I'll give it some more thought. Thanks!

@lgrapenthin
Copy link
Author

Thank you for thoughtful comment. I'd add that it can be worth the extra complexity. User level solutions require more complexity and are more error prone and have to be implemented by users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant