Skip to content

Option to and to_line results in ERR_STREAM_PREMATURE_CLOSE #410

Closed

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.

Activity

  1. slifty commented on Dec 8, 2023

    @slifty
    Author

    Thank you for the fast turnaround on this @wdavidw!

  2. wdavidw commented on Dec 8, 2023

    @wdavidw
    Member

    Gosh, I burned my day on it and it is not really fixed considering that I had to re-open #333!

  3. slifty commented on Dec 8, 2023

    @slifty
    Author

    Argh I'm sorry -- I'll see if I can find a cycle soon to at least try to help think about #333 (there are so many moving parts with node streams these days!)

  4. wdavidw commented on Dec 8, 2023

    @wdavidw
    Member

    With great pleasure, I tried all the variations that come into my head without a suitable solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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