nickewing / line-reader

Asynchronous line-by-line file reader for node.js
MIT License
452 stars 76 forks source link

Reading same line multiple times #15

Closed sami-sweng closed 7 years ago

sami-sweng commented 10 years ago

When multiple workers use the same reader in parallel, with hasNextLine() and nextLine(), some lines are read multiple times.

lfdoherty commented 9 years ago

Just making a note here that this was the true cause of the problem I logged as bug #21. If it's not going to be fixed I strongly suggest a note be added to the documentation warning that it's unsafe to do this.

lfdoherty commented 9 years ago

I should also add that it's not as simple as some lines being read multiple times - text may be mangled within a line (possibly if it spans more than one data chunk?)

amitguptagwl commented 8 years ago

I found a bug today on the same line. If I create a file with single line, lineReader.eachLine() keeps running forever.

var lineReader = require('line-reader');

lineReader.eachLine('testfile', function(line, last) {
    console.log(line);
});

But if there are more than one line even if they are empty. it works fine.

nickewing commented 8 years ago

@amitguptagwl What version of line-reader are you using? There are tests for both a file with a single line and a new line character and a file with a single line and no new line character. Are you also using workers like the previous posters?

amitguptagwl commented 8 years ago

I am using "line-reader": "^0.3.0". I dint realized that there is a new version available. Let me update and try again.

amitguptagwl commented 8 years ago

Thanks It is fixed in 0.4.0

nickewing commented 8 years ago

Cool, glad to hear it. :+1: