-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
fix(core): Order of module destroy should be the reverse of module init #14111
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build cbf75015-de20-4745-afe3-883731c322a1Details
💛 - Coveralls |
222c741
to
34c2cca
Compare
Let's consider the following example:
In summary, although reversing the order might seem intuitive, it actually creates more issues than it resolves. Especially since B should never interact directly with A unless a circular relationship is introduced—in which case, the order wouldn’t matter anyway. |
@kamilmysliwiec I completely agree with your view on the order of the onModuleDestroy sequence, and this PR aims to achieve that expected order as well. The current behavior does not align with the expected sequence. Assumption: The current test incorrectly expects nest/integration/hooks/e2e/on-module-destroy.spec.ts Lines 43 to 83 in bc4667c
My PR expects nest/integration/hooks/e2e/on-module-destroy.spec.ts Lines 43 to 78 in 34c2cca
|
@kamilmysliwiec I’ve created a minimal reproduction code. Please take a look. https://github.com/wenlong-chen/nest-on-module-destory-bug The following code throws an error during shutdown, which is unexpected. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Suppose A depends on B, currently, A.onModuleDestroy is executed after B.onModuleDestroy.
Issue Number: #14118
What is the new behavior?
Suppose A depends on B, A.onModuleDestroy is executed before B.onModuleDestroy.
Does this PR introduce a breaking change?
Other information