Repository navigation
External objects should not be modified #7655
Copy link
Copy link
Closed
Labels
discussIssues opened for discussion and feedback.Issues opened for discussion and feedback.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
Description
Activity
- addeddiscussIssues opened for discussion and feedback.Issues opened for discussion and feedback.lib / srcIssues and PRs involving general changes in the lib/ or src/ directories.Issues and PRs involving general changes in the lib/ or src/ directories.
on Jul 11, 2016 I don't know of any written rule but I agree that we should not modify user-supplied objects.
We can solve this problem for
optionsin #7165 by making a copy.We can solve this problem for options in #7165 by making a copy.
Another way is to do
options = Object.create(options);@thefourtheye yes, it would be a good place to add a solution for the
fsmodule, I could not find yet this issue for other core modules.util._extend()should be used in this case I guess@thefourtheye as I know from #7208 and #7255
Object.assign()performs slower thanutil._extend()and it was decided to use it untilObject.assign()will have a better performance- addedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.and removedlib / srcIssues and PRs involving general changes in the lib/ or src/ directories.Issues and PRs involving general changes in the lib/ or src/ directories.
on Jul 12, 2016 @micnic Right. I use
util._extendnow.Fixed in 7542bdd
- added a commit that references this issue
on Oct 10, 2016 - added a commit that references this issue
on Jul 27, 2026
Metadata
Metadata
Assignees
Labels
discussIssues opened for discussion and feedback.Issues opened for discussion and feedback.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
Hey, I was playing around with
Object.seal()andObject.freeze()and discovered that internally Node is trying to modify my objects and I got the following infs.watch:In my opinion external objects should not be modified by Node, as I observed sometimes this rule is respected, sometimes - only partially (in case of
fs.appendFile).Do we have anywhere this rule specified?
cc @nodejs/collaborators