question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Cannot abort a stream that already has a writer`

See original GitHub issue

Hi, 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:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
MattiasBuelenscommented, Sep 20, 2021

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 for pipeTo, specifically these:

  • Errors must be propagated forward: if source is or becomes errored, then abort the destination.
  • Errors must be propagated backward: if destination is or becomes errored, then cancel the source.

This polyfill does implement these requirements, see the source.

May I suggest a different approach? Instead of building a separate version of pipeTo that 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, including pipeTo. 😉

EDIT: Forget to mention, it’s published as @mattiasbuelens/web-streams-adapter.

0reactions
shakamdcommented, Sep 21, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found