Repository navigation
Conversation
Calling the fs.Stats constructor directly, with or without new, now throws ERR_ILLEGAL_CONSTRUCTOR. fs.Stats instances are only created internally. The class remains exported from node:fs so that instanceof checks continue to work. Internally, instances are constructed through a private symbol. This has been a runtime deprecation since v22.0.0. Refs: nodejs#52067 Refs: nodejs#51879 Assisted-by: Claude Signed-off-by: James M Snell <jasnell@gmail.com>
Collaborator
|
Review requested:
|
jasnell
commented
Nov 15, 2026
jasnell
commented
Nov 15, 2026
Co-authored-by: James M Snell <jasnell@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67491 +/- ##
==========================================
- Coverage 90.67% 90.65% -0.02%
==========================================
Files 799 799
Lines 280245 280249 +4
Branches 54125 54114 -11
==========================================
- Hits 254100 254068 -32
- Misses 16280 16291 +11
- Partials 9865 9890 +25
🚀 New features to boost your workflow:
|
gurgunday
approved these changes
Nov 15, 2026
Collaborator
Member
Author
|
@nodejs/tsc ... will need another sign off here |
bjohansebas
approved these changes
Nov 15, 2026
LiviaMedeiros
left a comment
Member
There was a problem hiding this comment.
I think this shouldn't land until we have better alternative (e.g. fs.isStats()) to instanceof Stats that we can recommend in the docs, or make such instanceof work with BigIntStats as well.
Comment on lines
+4069
to
+4070
| for public use. The class remains exported, so `instanceof fs.Stats` checks | ||
| continue to work. |
Member
There was a problem hiding this comment.
This recommendation doesn't look correct, because
fs.statSync('/etc/hosts') instanceof fs.Stats === true
// however:
fs.statSync('/etc/hosts', { bigint: true }) instanceof fs.Stats === false
// and:
fs.BigIntStats === undefined
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.
Calling the fs.Stats constructor directly, with or without new, now throws ERR_ILLEGAL_CONSTRUCTOR. fs.Stats instances are only created internally.
The class remains exported from node:fs so that instanceof checks continue to work. Internally, instances are constructed through a private symbol.
This has been a runtime deprecation since v22.0.0.
Refs: #52067
Refs: #51879