Skip to content

fs.createReadStream doesn't throw with options={start:NaN,end:NaN} #19715

@anliting

Description

@anliting

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 with a.mjs:

import fs from 'fs'
function length(rs){
    return new Promise(res=>{
        let a=[]
        rs.on('data',[].push.bind(a))
        rs.on('end',e=>{
            res(Buffer.concat(a).length)
        })
    })
}
fs.writeFileSync('hello.txt','world')
;(async()=>{
    // print 5 0 0
    console.log(
        await length(fs.createReadStream('hello.txt')),
        await length(fs.createReadStream('hello.txt',{start:NaN,end:NaN})),
        await length(fs.createReadStream('hello.txt')),
    )
})()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions