Skip to content

fix(core): prevent injector hang when design:paramtypes is missing#16683

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
Youmoo:fix/injector-sparse-array-hang
Apr 3, 2026
Merged

fix(core): prevent injector hang when design:paramtypes is missing#16683
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
Youmoo:fix/injector-sparse-array-hang

Conversation

@Youmoo

@Youmoo Youmoo commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

When emitDecoratorMetadata is unavailable (e.g. esbuild), @Inject() decorators create a sparse array via SELF_DECLARED_DEPS_METADATA. Array.prototype.map skips sparse holes, so the Barrier in resolveConstructorParams never receives enough signals and hangs indefinitely.

Use Array.from() in reflectConstructorParams to convert sparse arrays into dense arrays with explicit undefined values, ensuring map iterates every index and the Barrier resolves correctly.

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?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

When `emitDecoratorMetadata` is unavailable (e.g. esbuild), `@Inject()`
decorators create a sparse array via `SELF_DECLARED_DEPS_METADATA`.
`Array.prototype.map` skips sparse holes, so the `Barrier` in
`resolveConstructorParams` never receives enough signals and hangs
indefinitely.

Use `Array.from()` in `reflectConstructorParams` to convert sparse
arrays into dense arrays with explicit `undefined` values, ensuring
`map` iterates every index and the Barrier resolves correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coveralls

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 5b453f7a-8504-40fb-838b-26f8af740f6c

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 89.903%

Totals Coverage Status
Change from base Build bcb7b573-9798-42cb-a347-1d1f9e70592c: 0.05%
Covered Lines: 7604
Relevant Lines: 8458

💛 - Coveralls

@kamilmysliwiec kamilmysliwiec merged commit 59dba14 into nestjs:master Apr 3, 2026
2 checks passed
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