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

EntityCommands::insert panics when the entity is despawned, which is a footgun #9378

Closed
SludgePhD opened this issue Aug 7, 2023 · 1 comment

Comments

@SludgePhD
Copy link
Contributor

EntityCommands::insert will panic if the entity it is adding a bundle to is removed by any other system in the same tick, unless there's an apply_deferred system that runs between those systems.

This is often very difficult to notice, since the insertion might conflict with an entirely unrelated system that just so happens to also run in the Update schedule. In my particular case, I believe I have accidentally made a preexisting race condition like this much more likely by loosening some unnecessary ordering constraints between some completely unrelated systems.

I believe that EntityCommands::insert could be made much less difficult to use correctly if its behavior with a non-existent entity would instead be to simply do nothing, rather than to panic. This would also match the behavior of EntityCommands::remove and remove_resource, which do nothing when the thing they remove doesn't exist, or when their entity doesn't exist. Thoughts?

@SludgePhD
Copy link
Contributor Author

Ah, this is a duplicate of #7118.

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