Skip to content

Option to and to_line results in ERR_STREAM_PREMATURE_CLOSE #410

@slifty

Description

@slifty

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions