aglio icon indicating copy to clipboard operation
aglio copied to clipboard

allow to read longer files from stdin

Open anentropic opened this issue 5 years ago • 0 comments

Trying to read large blueprints from stdin fails, giving a syntax error which suggests the content was truncated. Reading the same file in via -i <filename> method works fine, so there is no issue with the file itself.

The length of the content I got was always 65536 bytes, suggesting some issue around buffering.

After experimenting it turns out that what actually happens is the process.stdin.on 'readable' event handler gets called multiple times for large files - for each block of data from the buffer.

So the fix is to build up the blueprint content over a series of readable events and wait until the end event is triggered before trying to process it.

anentropic avatar Apr 07 '19 23:04 anentropic