jimmywarting / StreamSaver.js

StreamSaver writes stream to the filesystem directly asynchronous
https://jimmywarting.github.io/StreamSaver.js/example.html
MIT License
4.04k stars 418 forks source link

Prevent ServiceWorker timeout on Firefox #83

Closed TexKiller closed 5 years ago

TexKiller commented 5 years ago

Ping the ServiceWorker every 29 seconds to prevent Firefox's 30 seconds timeout

jimmywarting commented 5 years ago

Have you tested it? dose it work?

TexKiller commented 5 years ago

Yes, I have, and yes, it does. :)

I have set up an example that writes 3600 'a' letters into a stream in the course of an hour. The download fails after about 30 seconds when I use the current github.io version of StreamSaver.js: https://texkiller.eu.org/StreamSaver/firefox-timeout/github.html

However, with this commit applied that does not happen and the download is completed after 1 hour: https://texkiller.eu.org/StreamSaver/firefox-timeout/

By the way, this obviously doesn't work on HTTP pages since the popup is closed immediately after the download starts, and therefore it doesn't ping the ServiceWorker. You can test this here, but make sure you don't have the previous link open since it's iframe will keep the ServiceWorker alive regardless: http://texkiller.eu.org/StreamSaver/firefox-timeout/http.html

This was all tested on Firefox 65.0.

jimmywarting commented 5 years ago

Grate test page! ❤️ tested it myself and you stand correct