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

Detect Abort Events in Service Worker #1284

Closed
anthumchris opened this issue Mar 5, 2018 · 1 comment
Closed

Detect Abort Events in Service Worker #1284

anthumchris opened this issue Mar 5, 2018 · 1 comment

Comments

@anthumchris
Copy link

It would be great if Service Workers could detect the "abort" event that should fire on the DOM when users cancel a document load (e.g. window.stop(), ESC key, browser stop button). Perhaps:

  1. SWs could detect "abort" events directly.
  2. SWs could detect "aborts" indirectly (via "onmessage" event handlers triggered by application). This doesn't currently seem possible, because the "abort" event doesn't currently fire on the DOM (See "abort" Event Isn't Fired When Aborting Document Load whatwg/html#3525).

This would be specifically useful when implementing custom Streams in Service Workers. The SW could detect "abort" events, close open streams, do cleanup, or send notifications to the underlying application.

For example, this SW progress indicator demo (https://fetch-progress.anthum.com/sw-basic/) implements a ReadableStream and has no way to for the SW to respond when the document load is aborted. Additionally, the network transfer continues in Chrome (Firefox successfully stops it), which may be different issue entirely.

@jakearchibald
Copy link
Contributor

This was solved in 5474d11, but I don't think there are any implementations yet.

More details: https://developers.google.com/web/updates/2017/09/abortable-fetch#in_a_service_worker.

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