Skip to content

fs: improve argument handling for ReadStream

Improve handling of erratic arguments in fs.ReadStream

Refs: https://github.com/nodejs/node/pull/19732

For the uninitiated, a summary of what I'm planning to change:

Type Current Behavior Proposed Behavior
undefined (0, Infinity) (0, Infinity)
Anything other than Number ERR_INVALID_ARG_TYPE ERR_INVALID_ARG_TYPE
NaN ERR_INVALID_ARG_TYPE ERR_OUT_OF_RANGE
Negative Numbers ERR_OUT_OF_RANGE
Fractional Numbers Math.round
Integers Work Perfectly Still work perfectly
Invalid Arguments ERR_OUT_OF_RANGE ERR_OUT_OF_RANGE
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

cc @addaleax @anliting @nodejs/fs

Merge request reports

Loading