Skip to content

fix(core): dependency injection edge case with moduleref.create#16637

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
JakobStaudinger:moduleref-create-transient-scope-reproduction
Mar 30, 2026
Merged

fix(core): dependency injection edge case with moduleref.create#16637
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
JakobStaudinger:moduleref-create-transient-scope-reproduction

Conversation

@JakobStaudinger

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Injecting a Scope.TRANSIENT dependency into a regular @Injectable that's instantiated with ModuleRef.create results in a "phantom" class, that's not correctly instantiated - the dependencies of the transient service that are not injected.

What is the new behavior?

The dependencies of the transient service are injected correctly.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Disclaimer: the fix was made by an LLM. I simply provided the .spec.ts file and asked it to fix it, I don't understand NestJS deeply enough to understand the fix fully.

Besides that, I didn't know where I should place the test file, open to suggestions if the current place is unfitting 😄

@coveralls

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 418d0a06-962c-43dd-b62b-c99d2704a8b1

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 89.856%

Totals Coverage Status
Change from base Build 6236cae6-7cf0-4fee-b50e-9546cfab30b0: 0.02%
Covered Lines: 7600
Relevant Lines: 8458

💛 - Coveralls

@kamilmysliwiec kamilmysliwiec merged commit f7d4460 into nestjs:master Mar 30, 2026
2 checks passed
@kamilmysliwiec

Copy link
Copy Markdown
Member

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants