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

notification of cancelled download? #957

Closed
Spongman opened this issue Aug 17, 2016 · 9 comments
Closed

notification of cancelled download? #957

Spongman opened this issue Aug 17, 2016 · 9 comments

Comments

@Spongman
Copy link

Spongman commented Aug 17, 2016

If a ServiceWorker's 'fetch' event responds with a Response with a 'Content-Disposition': 'attachment; filename=blah' header, the browser starts a download.

Is there any way for the ServiceWorker to know if/when the user cancels the download (in the chrome://downloads/ window)?

I would have expected the cancel(reason) method of the Response stream's underlyingSource to be called. But in Chrome v52.0.2743.116, it's not.

@wanderview
Copy link
Member

Maybe with ReadableStream? You could interpose a js monitor and observe if the stream is closed before its fully read. The browser may read ahead and buffer though.

@Spongman
Copy link
Author

I'm passing a ReadableStream into the Response's constructor. The stream's underlyingSource has a 'cancel' method, but that is never called. Also, i can call controller.enqueue without error after the download is cancelled.

@domenic
Copy link
Contributor

domenic commented Aug 17, 2016

That just sounds like a bug in Chrome to me... /cc @yutakahirano

@yutakahirano
Copy link
Contributor

Thank you for reporting, I filed a bug.

@Spongman
Copy link
Author

Thanks. I think it's fantastic that Chromium even handles this at all (I didn't see anything about attachments in the SW spec, though). IMHO being able to completely customize how the browser does downloads is a game-changer for us: we're using it to concurrently stream chunks of multiple huge, CDN-hosted files directly into a client-side archive.

@jakearchibald
Copy link
Contributor

Eventually we'll also have a cancel token on the fetch event to signal a cancellation of the request.

@Spongman
Copy link
Author

why was this closed? is this fixed?

@Spongman
Copy link
Author

did anything happen with this, or did it just get swept under the rug?

@jakearchibald
Copy link
Contributor

Nothing's been swept under the rug. Read the comments above.

This tracker is for spec issues, but what you identified was a Chrome bug. A ticket to the Chrome bug was posted above, and this issue was closed because there's no change to the spec needed.

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

5 participants