-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Error thrown on moduleRef.resolve()
is a breaking change
#4866
Comments
Why default scoped should not be allowed? |
Same problem. I understand that Also, we need a better exception message at least, now it says "... is marked as a scoped provider ... Please, use "resolve()" instead", but
As a workaround I had to set all these providers to TRANSIENT scope. Thanks for a great framework btw. |
@maximelkin The reasoning behind this makes sense given how Nest's injector works behind the scenes. The idea is that I think a case could be made for having a method available that does either/or...it's not always easy to know when a particular provider is request scoped or not (although frequently this is a red flag for abusing the provider scopes). |
@janhartigan thank you! My bad, not carefully read the docs |
I've also encountered recently this issue while upgrading the dependencies to a minor version. The error is really confusing, because I always call
If the real intent is to allow For all the usage mentioned here, the fix is simple - read the |
Since there's no easy way to dynamically determine the scope of a provider, I've reverted this breaking change for now (+ error message was misleading either way 😅 ). Fixed in the latest release! |
Bug Report
Current behavior
Calling
moduleRef.resolve()
on non-transient providers throws an error when it did not before 7.1.2.The relevant commit is:
439736f
Input Code
Expected behavior
I understand that
resolve
should only be called for transient-scoped providers, but before this update, it did not throw an error when not doing so. This is a breaking change introduced in a patch version. I have full coverage in my repos, so I was able to catch this, but for anyone who is relying on Nest not to release breaking changes in minor updates, this will be a problem.Possible Solution
Revert the change. Re-introduce it in a major version update.
The text was updated successfully, but these errors were encountered: