You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there an existing issue that is already proposing this?
I have searched the existing issues
Potential Commit/PR that introduced the regression
No response
NestJS version
9.0.11 -> 9.1.1+
Describe the regression
Injecting the request into a factory provider no longer works if the provider is subject to a custom context id strategy. Request object is undefined.
When you look at the implementation in the linked repo, there is one module that deals with multitenancy. It contains a ContextIdStrategy that is more or less a copy of the one that can be found in the official documentation. It is used to create a DI subtree based on a tenant-id http header.
The module also contains a factory provider that is used to inject the tenant id, when it needs to be used by a service. In the linked repo, the echo-service is injected with the tenant-id from the request via the factory provider. Then the echo service exposes the tenantId to the controller which sends it back to the caller.
When using nestjs 9.0.11, the code of the repo works without issues. When using 9.1.1+ the code breaks.
request object was never meant to be auto-registered for durable trees as that would simply lead to memory leaks. This behavior was never documented & described in the docs. We fixed this issue in 9.1.1.
Did you read the migration guide?
Is there an existing issue that is already proposing this?
Potential Commit/PR that introduced the regression
No response
NestJS version
9.0.11 -> 9.1.1+
Describe the regression
Injecting the request into a factory provider no longer works if the provider is subject to a custom context id strategy. Request object is undefined.
When you look at the implementation in the linked repo, there is one module that deals with multitenancy. It contains a ContextIdStrategy that is more or less a copy of the one that can be found in the official documentation. It is used to create a DI subtree based on a
tenant-id
http header.The module also contains a factory provider that is used to inject the tenant id, when it needs to be used by a service. In the linked repo, the echo-service is injected with the tenant-id from the request via the factory provider. Then the echo service exposes the tenantId to the controller which sends it back to the caller.
When using nestjs 9.0.11, the code of the repo works without issues. When using 9.1.1+ the code breaks.
Minimum reproduction code
https://github.com/ccaspers/nestjs-context-bug
Input code
No response
Expected behavior
The factory provider is injected with the request.
Other
No response
The text was updated successfully, but these errors were encountered: