lucagrulla / node-tail

The zero dependency Node.js module for tailing a file
https://www.lucagrulla.com/node-tail/
MIT License
467 stars 75 forks source link

Carriage Return (\r) is messing up Mac (not tail's fault) #159

Open zvictor opened 2 years ago

zvictor commented 2 years ago

My scripts fail to print the content of the files that tail is reading from. As result, many lines simply do not appear in console. I am running macOS Monterey 12.5 (21G72).

Doing some research I found this report that describes precisely my situation. I could also do some quite extensive debugging and confirmed that there is nothing wrong with tail. It's node that "eats" lines out when \r is present.

To workaround this issue I have set separator: /\r|\n/, and the problem is now gone. The question left here is: should we change the default separator value to better accommodate Mac users?

lucagrulla commented 2 years ago

Hello @zvictor

Let me check I understood the scenario well.

Your file uses \r as an end of line character. When that happens, the library "eats" the following lines. Is this correct? Or have I misunderstood?

zvictor commented 2 years ago

Yes, that's correct. Except that it's not the library, but actually node itself!

That's what happens when I ask node to print the bad string from stackoverflow: https://app.warp.dev/block/Fg16AyIidLvFoeYgAljxp9