-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs.createReadStream doesn't throw with options={start:NaN,end:NaN} #19715
Comments
If I'm not wrong, this should just involve adding a simple check at https://github.com/nodejs/node/blob/master/lib/fs.js#L1976, something on the lines of: if (Number.isNaN(options.start) || Number.isNaN(options.end)) {
throw new Error(...) // Perhaps a RangeError would be more fitting?
} Let me know if it sounds about right and I'll submit a PR promptly. |
Similar checking can be found here (https://github.com/nodejs/node/blob/master/lib/fs.js#L2010-L2026), so I think it might be more appropriate to make a patch here, for the sake of maintainability.
I would fix it like this: https://github.com/anliting/node-1/blob/master/lib/fs.js#L2010-L2030 |
@anliting I've made the change at the exact same place. |
This test makes fs.ReadStream throw an error when either start or end is NaN. Fixes: nodejs#19715
|
@arboreal84 Check out #19732 if it solves your issue. |
@arboreal84 I don't think |
Make ReadStream (and thus createReadStream) throw a TypeError signalling towards an invalid argument type when either options.start or options.end (or obviously, both) are set to NaN. Also add regression tests for the same. Fixes: nodejs#19715
Make ReadStream (and thus createReadStream) throw a TypeError signalling towards an invalid argument type when either options.start or options.end (or obviously, both) are set to NaN. Also add regression tests for the same. PR-URL: nodejs#19775 Fixes: nodejs#19715 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
I think it would be better to throw in the following case. The following case also causes every newly created read stream to end immediately.
$ node --experimental-modules a.mjs
witha.mjs
:The text was updated successfully, but these errors were encountered: