Repository navigation
fix(common): preserve sparse array length in default value pipe - #18551
Merged
kamilmysliwiec merged 1 commit intoNov 18, 2026
Merged
Conversation
2 of 4 tasks
4 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #18548
PR Checklist
Please check if your PR fulfills the following requirements:
Documentation changes are not needed: this restores preservation of the configured default's array length without introducing an API change.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
DefaultValuePipe loses trailing empty slots when copying a sparse array default. For example,
new Array(7)becomes an empty array, changing the value passed to the handler.Issue Number: #18548
What is the new behavior?
Restore the source array's length after copying its enumerable properties. This preserves sparse array length while retaining the existing allocation for dense arrays, as suggested in the issue discussion.
Adds regression tests for arrays containing only empty slots, a populated index followed by empty slots, and a sparse array nested inside a plain object. The tests also check that copies remain separate and empty slots are preserved.
Does this PR introduce a breaking change?
Other information
Validated on Windows with Node.js 22.19.0:
npm run test -- packages/common/testwithNO_COLORunset: 88 files, 1,169 tests passed, including the three regressions.tsc --project packages/common/tsconfig.build.json --noEmit): passed.git diff --check: passed.npm run lint:ci: exit 0, with an existing optional-chain warning inpackages/websockets/socket-module.ts.The full unit suite was attempted on Windows but exited 1. Running the unchanged
packages/core/test/nest-application-context.spec.tsseparately reproduces an unexpected Vitest worker exit in its shutdown-signal test. The full suite therefore has not passed cleanly in this environment. Integration tests have not been run.