-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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): Making Request scope non durable win over scope durable #10698
fix(core): Making Request scope non durable win over scope durable #10698
Conversation
If an instance has at least one dependency that is Request scope non durable, then the instance should be Request scope non durable itself. Closes nestjs#10594
a4a8503
to
a21eb2e
Compare
could you please open a PR at https://github.com/nestjs/docs.nestjs.com to clarify this new behavior? |
@micalevisk PR to the docs doesn't seem to be needed (it should work as intended upon merging this PR) |
@kamilmysliwiec @micalevisk I do wonder if I also need to check the Dynamic Modules that use a factory. With my tests it seems that if at least one injected dependency to the factory method is durable then that factory method becomes durable even though it has some other dependencies that are Request non durable. |
Actually I need to dig a bit further because I see the problem while using |
Ok I think I spotted the issue in my tests. The My class definition @Injectable({ scope: Scope.REQUEST, durable: false })
export class M2MTenantAuthService { in my test .overrideProvider(M2MTenantAuthService).useValue(m2mTokenMock) and this is the debug data I got for that class Notice the Wondering if because I use Anyway nothing to add to this PR. |
yeah, looks like there's no way to define the scope of overwrited providers when using nest/packages/testing/testing-module.builder.ts Lines 91 to 95 in eebb976
|
In theory it should maintain the scope defined in the original provider. |
@kamilmysliwiec any idea when this can be merged and released? |
@micalevisk @kamilmysliwiec @Papooch just a little nudge to know when we can expect this to be merged. |
it is but I didn't notice before that maybe yours would fix that issue as well but in a more cleaner way. To clarify: I'm not asking you to bring those changes to here, but to check out if the bug described in there will be fixed by this PR. |
sure, I'll have a look. |
Just found that the enhancers tests are failing. Investigating... |
lgtm |
seems like this has introduced a regression: #11002 |
If an instance has at least one dependency that is Request scope non durable, then the instance should be Request scope non durable itself.
Closes #10594
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?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information