Skip to content
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

Option to and to_line results in ERR_STREAM_PREMATURE_CLOSE #410

Closed
slifty opened this issue Dec 6, 2023 · 4 comments
Closed

Option to and to_line results in ERR_STREAM_PREMATURE_CLOSE #410

slifty opened this issue Dec 6, 2023 · 4 comments

Comments

@slifty
Copy link

slifty commented Dec 6, 2023

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.

@wdavidw wdavidw closed this as completed in 0df32c6 Dec 8, 2023
@slifty
Copy link
Author

slifty commented Dec 8, 2023

Thank you for the fast turnaround on this @wdavidw!

@wdavidw
Copy link
Member

wdavidw commented Dec 8, 2023

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

@slifty
Copy link
Author

slifty commented Dec 8, 2023

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!)

@wdavidw
Copy link
Member

wdavidw commented Dec 8, 2023

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants