Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How To: Reusing body mixin streams #1326

Closed
shellscape opened this issue Apr 6, 2022 · 1 comment
Closed

How To: Reusing body mixin streams #1326

shellscape opened this issue Apr 6, 2022 · 1 comment

Comments

@shellscape
Copy link
Contributor

This is being left here to make it searchable:

If the scenario arises where you absolutely must have a copy of the result stream, .clone can be used before using a body mixin, or body.pipeThrough with a user-defined stream §, such as [TransformStream]https://nodejs.org/api/stream.html#duplex-and-transform-streams.

@restfulhead
Copy link

@shellscape I don't think pipeThrough works. It still marks the body as consumed.

console.log(request.bodyUsed)
request.body.pipeThrough(new TextDecoderStream())
console.log(request.bodyUsed)

This prints out false, then true. How can we copy/clone the stream without causing bodyUsed to become true?

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

No branches or pull requests

2 participants