Option to and to_line results in ERR_STREAM_PREMATURE_CLOSE (original) (raw)

Describe the bug

When I try setting to_line or to to a value that is NOT the end of the file, node throws a ERR_STREAM_PREMATURE_CLOSE at me.

To Reproduce

const csvPath = 'myFilewithMoreThanTwoRows.csv'; const parser = fs.createReadStream(csvPath).pipe( parse({ to_line: 2, }), ); for await (const record of parser) { process.stdout.write(${record.join(',')}\n); }

Additional context

This seems like it might be related to the changes made for #333.
In this example, if the CSV only has 2 rows then there's no issue.