You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs: too strict range check on 'mode' parameter #20498
Since version 10, function like fs.chmod() or fs.mkdir() check if their mode parameter is below o777throwing 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?
cc @targos@BridgeAR We discussed about unifying this check in #19973 (review) I am leaning towards masking off the relevant bits since that's what the underlying POSIX API usually does.
Hi,
I just wanted to mention that I also encountered this bug. It happens when I use Gulp (graceful-fs) on Gitlab CI:
RangeError [ERR_OUT_OF_RANGE]: The value of "mode" is out of range. Received 33206
at Object.fs.fchmod (fs.js:1024:11)
at Object.fchmod (/builds/demurgos/node-devkit/node_modules/graceful-fs/polyfills.js:237:17)
at mode (/builds/demurgos/node-devkit/node_modules/vinyl-fs/lib/file-operations.js:237:10)
at onStat (/builds/demurgos/node-devkit/node_modules/vinyl-fs/lib/file-operations.js:227:14)
at /builds/demurgos/node-devkit/node_modules/graceful-fs/polyfills.js:287:18
at FSReqWrap.oncomplete (fs.js:150:5)
Reacted by Eric M. Dantas, Benjamin Rancourt, Geoffrey Booth, atropo and Sp90
When it will be in master? 10.4.1 released but still
RangeError [ERR_OUT_OF_RANGE]: The value of "mode" is out of range. Received 33206
at Object.fs.fchmod (fs.js:1058:11)
Activity
arantes555 commentedon May 3, 2018
Seeing the same issue here. Breaking
graceful-fsactually breaksvinyl-fs, so it actually breaksgulp(yes, evengulp@4).In my case, I only see the issue when running on CI...
joyeecheung commentedon May 4, 2018
cc @targos @BridgeAR We discussed about unifying this check in #19973 (review) I am leaning towards masking off the relevant bits since that's what the underlying POSIX API usually does.
joyeecheung commentedon May 4, 2018
Also cc @jasnell the check is added in #17334
jasnell commentedon May 4, 2018
I'm good with masking off the bits and relaxing the check :)
jasnell commentedon May 4, 2018
Also, it's obvious we don't have good test coverage for this particular case so it would be good to expand that a bit.
BridgeAR commentedon May 4, 2018
I also agree that masking off seems the right thing to do.
demurgos commentedon May 6, 2018
Hi,
I just wanted to mention that I also encountered this bug. It happens when I use Gulp (graceful-fs) on Gitlab CI:
alanonthegit commentedon May 7, 2018
I'm having the same issue above with Gulp 4(graceful-fs) in my local build. What can I do to fix this?
seeker5084 commentedon May 8, 2018
same here.
seeker5084 commentedon May 10, 2018
graceful-fs's RangeError [ERR_OUT_OF_RANGE] solved by #20588.
Great work. Thanks!
52 remaining items
delagen commentedon Jun 14, 2018
When it will be in master? 10.4.1 released but still
RangeError [ERR_OUT_OF_RANGE]: The value of "mode" is out of range. Received 33206
at Object.fs.fchmod (fs.js:1058:11)
joyeecheung commentedon Jun 14, 2018
@delagen It's on v10.x-staging now, should be available in the next release.
delagen commentedon Jun 14, 2018
@joyeecheung This was broken for about 7 releases of 10.x branch. Speed of fixes make me sad (
bnoordhuis commentedon Jun 14, 2018
Comments like yours make me sad. It adds nothing except another notification email to 100+ people.
Update Node.js to v10.5.0 (#194)
Bump Node.js to 10.5
Downgrade node to v8 to work around nodejs/node#20498
lib: mask mode_t type of arguments with 0o777