Skip to content

🐛 Clean up resources when the AppFixture fails to initialize - #170

Merged
flovouin merged 2 commits into
mainfrom
fix/app-fixture-init-clean
Jul 31, 2026
Merged

🐛 Clean up resources when the AppFixture fails to initialize#170
flovouin merged 2 commits into
mainfrom
fix/app-fixture-init-clean

Conversation

@flovouin

@flovouin flovouin commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📝 Description of the PR

When the initialization of an AppFixture failed, the fixture was left in an inconsistent state: it was already considered active, although the application had not been created yet. Any subsequent lifecycle call passed its state check and then failed on the missing application, replacing the original error with a TypeError. Because delete threw before reaching the fixtures, none of them were ever cleaned up, and the resources they had allocated (temporary databases, subscriptions, clients) stayed alive past the end of the test file.

AppFixture.init now releases everything it has allocated when it fails: the application is closed and the fixtures that did initialize are deleted, before the original error is rethrown. The fixture becomes active only once the application is fully initialized, and it transitions to a failed state otherwise, in which clear and delete are no-ops. All fixtures are also initialized to completion even when one of them fails, so that a slower fixture cannot allocate resources after the cleanup has run.

📋 Check list

  • 🧪 Unit tests have been written.
  • 📝 Documentation has been updated.

@flovouin flovouin added the bug Something isn't working label Jul 31, 2026
@flovouin
flovouin merged commit f5d2bd3 into main Jul 31, 2026
2 checks passed
@flovouin
flovouin deleted the fix/app-fixture-init-clean branch July 31, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant