`Cannot abort a stream that already has a writer`
See original GitHub issueHi, thanks for this great polyfill first.
I want to close the WritableStream when the user cancels the download process, but it throws as title, is there any solution?
I’m using the hacky way currently.
if (evt.data.aborted) {
if (stream._writer) {
stream._writer.abort()
stream._writer = undefined
}
stream.abort()
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
WritableStream.abort() - Web APIs | MDN
The abort() method of the WritableStream interface aborts the stream, signaling that the producer can no longer successfully write to the ...
Read more >java IO Exception: Stream Closed - Stack Overflow
You're calling writer.close(); after you've done writing to it. Once a stream is closed, it can not be written to again.
Read more >Stream | Node.js v19.3.0 Documentation
Data is buffered in Writable streams when the writable.write(chunk) method is called repeatedly. While the total size of the internal write buffer is...
Read more >Streams—The definitive guide - web.dev
In a manner specific to the transform stream, writing to the writable ... `done` - `true` if the stream has already given you...
Read more >Spark Streaming Programming Guide
Before we go into the details of how to write your own Spark Streaming ... If you have already downloaded and built Spark,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

So basically you’ve built your own version of
ReadableStream.pipeTo()outside of this polyfill. The problem is that your version doesn’t implement all of the requirements forpipeTo, specifically these:This polyfill does implement these requirements, see the source.
May I suggest a different approach? Instead of building a separate version of
pipeTothat works with Firefox’s native streams, adapt the native stream into a polyfill stream first using e.g. web-streams-adapter. Then you can use the full API of the polyfill again, includingpipeTo. 😉EDIT: Forget to mention, it’s published as
@mattiasbuelens/web-streams-adapter.@JounQin, curious to see if you are able to solve this. I’m also trying to support user download cancellation in my app with streamsaver.