Skip to content

fs: fix confusing flags TypeError msg

Fix #2871 (closed), replace #2873. I did this on the plane back from NodeConf, it is basically the same change as #2873, but with more tests.

File open flags must be an int when passed to the binding layer, but they must be a string when passed to the fs module (numbers are permitted, though undocumented). The module used to do no type checking, so the binding layer error would be thrown, and it was wrong:

> fs.openSync('_')
TypeError: flags must be an int
    at TypeError (native)
    at Object.fs.openSync (fs.js:549:18)

It is now:

> fs.openSync('_')
TypeError: flag must be a string

Merge request reports

Loading