Skip to content

allow to read longer files from stdin#364

Open
anentropic wants to merge 1 commit intodanielgtaylor:masterfrom
anentropic:bugfix/read-stdin
Open

allow to read longer files from stdin#364
anentropic wants to merge 1 commit intodanielgtaylor:masterfrom
anentropic:bugfix/read-stdin

Conversation

@anentropic
Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant