I am trying to achieve following error handling:
- Say we have a
readablestream. - We pipe it into a
transformstream. - Somehow the
transformstream emits anerror. - We would like to recover the
readablestream (and all of its data), and re-pipe it into anothertransformstream.
Step 4 appears to be difficult: I can listen to unpipe event on the target stream (transform stream) and retrieve a reference to the source stream (readable stream), but at least some chunks of its data have been lost.
Can we do this without creating a custom transform stream?
A real-world example is deflate content encoding, where in some cases, you need zlib.createInflateRaw() instead of zlib.createInflate(), but we can't decide which one would be the correct choice before looking at the response body buffers.