This repository was archived by the owner on Feb 3, 2019. It is now read-only.
Fix for sporadic truncation of output files due to incomplete I/O#20
Open
pjeby wants to merge 1 commit intovavere:masterfrom
Open
Fix for sporadic truncation of output files due to incomplete I/O#20pjeby wants to merge 1 commit intovavere:masterfrom
pjeby wants to merge 1 commit intovavere:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi. I'm using htmltidy as part of a regression test, to compare output of a system with its previous output. On numerous occasions, one file out of hundreds processed will be truncated somewhere in the middle. After extensive analysis and experimentation, I determined that the problem seems to be due to Node sometimes firing the subprocess
exitevent shortly before the lastdataevent from the subprocess's stdout. (This is on Windows 7, by the way.)This one-line change fixes the problem for
tidy()calls, by delaying the final result callback until Node has finished processing all pending I/O, thus ensuring that the remainingdataevent has a chance to fire before the final callback is invoked.Without the patch, an average of about 1 (randomly selected) file per two thousand processed is truncated on my computer. But with the patch, none are ever truncated as far as I can tell.
(The build is a complex one, with lots of other streaming events going on left and right, so I imagine the event ordering is a little less deterministic than in simpler processes using htmltidy, or that are not invoking it hundreds of times in rapid succession.)