Node.js, stdout, and disappearing bytes

01-Nov-2024 116
Someone in one of my online communities recently asked about why their Node command was dropping output when piped to another command: [command] spits out 2319 lines of valid json to stdout. If I redirect it into a file then I can open that file and yes, see all 2319 lines and well formatted json. But when I pipe it to jq, it complains that the json terminates on line 1394 If I pipe to wc then it reports there are 1394 lines If I pipe to tee to write it to a file and then pipe that to wc it reports 1394 and the file indeed cuts off my json part way through the 1394th line There is nothing unusual about this line What could be going on?.
Use coupon code:

JAVASCRIPT

to get 40% discount on our 'The JavaScript Interview Bible' book!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle