diff --git a/demo/file/index.html b/demo/file/index.html index 49982e34..26086461 100644 --- a/demo/file/index.html +++ b/demo/file/index.html @@ -10,7 +10,7 @@ -

Sample database importer

+

Sample database import/export

diff --git a/demo/file/index.js b/demo/file/index.js index 93d853c5..30f3e29d 100644 --- a/demo/file/index.js +++ b/demo/file/index.js @@ -12,16 +12,18 @@ const DBFILE_MAGIC = 'SQLite format 3\x00'; navigator.serviceWorker.register('service-worker.js', { type: 'module' }); (async function() { // Enable the export button when the service worker is responding. + let delay = 25; + const start = performance.now(); while (true) { - let delay = 25; const response = await fetch('./export?check=true'); if (response.ok) { // @ts-ignore document.getElementById('file-export').disabled = false; return; } + if (performance.now() - start > 60_000) throw new Error('service worker timeout'); await new Promise(resolve => setTimeout(resolve, delay)); - delay = Math.min(delay * 2, 5000); + delay *= 2; } })();