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

Adding detecting circular dependecies #13

Closed
wants to merge 1 commit into from

Conversation

mamazu
Copy link

@mamazu mamazu commented Oct 7, 2024

When a service has a dependency on another service in the same chain, this will silently fail and run out of memory. This adds an exception if a service has a dependency on itself.

@dantleech
Copy link
Collaborator

this would also impact performance for every call to get at runtime...

@mamazu
Copy link
Author

mamazu commented Oct 7, 2024

Is there any other way of doing that? The alternative would be to add a build step like with the Symfony DI container.

@dantleech
Copy link
Collaborator

dantleech commented Oct 7, 2024

It could be done in a more efficient way probably, but with micro impact on performance (which isn't a problem with long running processes like Phpactor where it's just a small startup cost) but I'm still reluctant to change things on the hot-path or to add more complexity here.

Compiled containers introduce extra complexity with generally negative impact (can't use closures to build services, cache clearing etc, can't jump to instantiations as you can now etc).

@mamazu
Copy link
Author

mamazu commented Oct 7, 2024

I'm open for suggestions. It definitely helps finding problems with accidental circular dependencies and not just a generic "out of memory" exception.

See phpactor/phpactor#2749

@mamazu mamazu closed this Nov 5, 2024
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

Successfully merging this pull request may close these issues.

2 participants