fix(common): exclude built-in primitives from strip proto keys#16202
Merged
kamilmysliwiec merged 3 commits intonestjs:masterfrom Jan 23, 2026
Merged
fix(common): exclude built-in primitives from strip proto keys#16202kamilmysliwiec merged 3 commits intonestjs:masterfrom
kamilmysliwiec merged 3 commits intonestjs:masterfrom
Conversation
Skip constructor deletion for Date, RegExp, Error, Map, Set, WeakMap, and WeakSet to fix Jest useFakeTimers compatibility. Maintains prototype pollution protection for regular objects. Fixes nestjs#16195
2 tasks
Skip constructor deletion for Date, RegExp, Error, Map, Set, WeakMap, and WeakSet to fix Jest useFakeTimers compatibility. Maintains prototype pollution protection for regular objects. Fixes nestjs#16195
Pull Request Test Coverage Report for Build cf3c34e0-b22e-43f4-a75c-d04670b6fcedDetails
💛 - Coveralls |
Contributor
Author
|
Hi @kamilmysliwiec, When you have a moment, could you plaese review this pull request? All tests are passing locally and CI checks are green. Please let me know if any further adjustments or additional test cases are needed. |
| } | ||
|
|
||
| // Skip built-in JavaScript primitives to avoid Jest useFakeTimers conflicts | ||
| const builtInTypes = [Date, RegExp, Error, Map, Set, WeakMap, WeakSet]; |
Member
There was a problem hiding this comment.
Can we move this array outside this method? (preferebly above the class definition, or as a private static member)
Contributor
Author
There was a problem hiding this comment.
ok , I'll move it to a private static member for better performance.
Contributor
Author
|
Just wanted to check if there's anything I should improve in this PR to help with the review process. |
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.
Description
Fixes Jest
useFakeTimers()compatibility issue introduced in v11.1.10.Issue
Closes #16195
Changes
stripProtoKeysmethod to skip built-in JavaScript primitives (Date, RegExp, Error, Map, Set, WeakMap, WeakSet)Rationale
PR #16079 introduced constructor deletion for security, but Jest's fake Date objects have non-configurable constructor properties that cannot be deleted. This fix excludes built-in types while maintaining security for user-defined objects.
Testing