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

Add warnings for if a plugin is inserted twice #4973

Conversation

TheRawMeatball
Copy link
Member

Objective

A plugin being inserted multiple times can cause very subtle bugs that are hard to track down

Solution

Issue a warning if the same plugin is ever inserted multiple times to make tracking down such bugs easier.

@MinerSebas
Copy link
Contributor

MinerSebas commented Jun 9, 2022

I think that #3988 is better, as it either enforces that a plugin can only be used once or that a plugin explicitly says it can be used multiple times, instead of an unsuppressible warning like in this PR.

@TheRawMeatball
Copy link
Member Author

Ah, I didn't know that PR existed.

@@ -768,6 +771,14 @@ impl App {
T: Plugin,
{
debug!("added plugin: {}", plugin.name());
if !self
.world
.get_resource_or_insert_with(|| AddedPluginsRegistry(HashSet::new()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer it if we could avoid adding Resources that don't get used at runtime, instead opting to either embed it into the App itself, or bring back the old AppBuilder to discard this state after app construction is finalized.

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.

4 participants