Create a clean stream using fs.createReadStream#764
Open
Its-Just-Nans wants to merge 2 commits intohttp-party:masterfrom
Open
Create a clean stream using fs.createReadStream#764Its-Just-Nans wants to merge 2 commits intohttp-party:masterfrom
Its-Just-Nans wants to merge 2 commits intohttp-party:masterfrom
Conversation
Contributor
|
The idea was to reuse the stream and it works well with most supported versions of Node. Not sure how much of a performance issue it is to recreate the streamm and if it's worth fixing (#756 is not an issue with latest Node 12/14/16 and Node 10 is EOL) |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Relevant issues
#756
#634
The
streamis piped inres. Next the stream generate an errorThe first argument must be one of type string or Buffer. Received type numberand launchs thesatus["500"]()function then thestatus["500"]()function modify headers (after the piped stream), that's the crashing error appear.To counter that, the stream musn't create error, we can :
stream = Readable.from(bytes)tostream = Readable.from(bytes.toString())stream = Readable.from(bytes)because a correct stream is created with line 334BUT using .toString() format the buffer and a different charset can produce an error (see
toString()innpm run test).This PR is the second (and working) option
Contributor checklist
--helpoutputmasterbranchMaintainer checklist