This repository was archived by the owner on Jun 24, 2022. It is now read-only.
Add test to verify end is called at the appropriate time. #45
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.
Add a testcase which demonstrates that 'end' is being called while a stream is paused. This can be problematic if you are doing async processing of data. In my case I use streams to process Section data and retrieve the teacher and student data related to the section. (I do this in batches only requesting information not yet seen to avoid unnecessary API requests.) As end is being called while the stream is supposed to be paused, something the Node.js docs for Readable streams indicates should not happen, it caused me to early exit the function resulting in reports of data syncs being inaccurate, and worse could cause other data not to fully sync as those tasks were still in process.
I have worked around the issue by using an additional promise which only resolves once I am done with the async processing and have resumed the stream. This, however, should not be necessary. The current behavior is incorrect and can lead to unwitting errors in implementations relying on the streaming behavior.