- Version: 10.0.0
- Platform: MacOS 10.12.6 (Sierra)
- Subsystem: fs
Since version 10, function like fs.chmod() or fs.mkdir() check if their mode parameter is below o777 throwing a RangeError exception if the condition isn't satisfied.
This requirement is too strict as the mode parameter can often be above o777 if it need to set the S_ISUID or S_ISGID bits.
Furthermore this range check break several node packages (e.g. graceful-fs used by over 1400 other packages) in a very common scenario:
A program wants to create a new file/directory with the same rights that a reference file/directory. Often the mode attribute of fs.Stats object is directly passed to fs.chmod() or fs.mkdir(). However the fs.Stats.mode is always above o777 (e.g. o100644) since it also contains the file type bits.
Classic POSIX version of chmod or mkdir seems to handle those kind a values without complaining by discarding the irrelevant bits instead of throwing an error. Why do Node need to be so brutal about it?
Since version 10, function like
fs.chmod()orfs.mkdir()check if theirmodeparameter is belowo777throwing a RangeError exception if the condition isn't satisfied.This requirement is too strict as the mode parameter can often be above
o777if it need to set theS_ISUIDorS_ISGIDbits.Furthermore this range check break several node packages (e.g.
graceful-fsused by over 1400 other packages) in a very common scenario:A program wants to create a new file/directory with the same rights that a reference file/directory. Often the
modeattribute offs.Statsobject is directly passed tofs.chmod()orfs.mkdir(). However thefs.Stats.modeis always aboveo777(e.g.o100644) since it also contains the file type bits.Classic POSIX version of
chmodormkdirseems to handle those kind a values without complaining by discarding the irrelevant bits instead of throwing an error. Why do Node need to be so brutal about it?