aglio
aglio copied to clipboard
allow to read longer files from stdin
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.