Fix with a patch
2 unresolved threads
2 unresolved threads
Closes #3477135
Merge request reports
Activity
101 101 action: 'service_worker_activated' 102 102 }) 103 103 }); 104 worker.addEventListener('fetch', event => php.handleFetchEvent(event)); 104 worker.addEventListener('fetch', event => { 105 const url = new URL(event.request.url); 106 if (url.pathname.endsWith('.so') || url.pathname.endsWith('.zip') || url.pathname.endsWith('.phpcode') || url.pathname.endsWith('.wasm')) { 107 // Don't download it. These are basically fetch from another service worker, 108 // and never something we want to pass to the CGI worker. 109 return; 110 } 111 return php.handleFetchEvent(event); - Comment on lines -104 to +111
Okay, so the dedicated worker makes an HTTP request and this is causing it to happen twice? Or is it due to the service worker itself downloading something.
Reviewing https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent
I wonder if we can check the client ID instead of checking extensions.
Yep, here's the bug:
handleFetchEvent(event) { const url = new URL(event.request.url); const prefix = this.prefix; if(url.pathname.substr(0, prefix.length) === prefix && url.hostname === self.location.hostname) { requestTimes.set(event.request, Date.now()); const response = this.request(event.request); return event.respondWith(response); } else { return fetch(event.request); } }
https://github.com/seanmorris/php-wasm/blob/master/source/PhpCgiBase.js#L171-L174
This should just do nothing and not
fetch
changed this line in version 5 of the diff
25 }) 26 php.addEventListener('output', event => { 27 event.detail.forEach(detail => { 28 try { 29 const data = JSON.parse(detail.trim()); 30 postMessage({ 31 action: `status`, 32 params, 33 ...data 34 }) 35 } catch (e) { 36 console.log(detail) 37 } 38 }) 39 }); 40 php.addEventListener('error', event => console.log(event.detail)); changed this line in version 8 of the diff
added 10 commits
-
a765d7cb - 1 commit from branch
project:0.x
- eaef19a8 - Fix with a patch
- 31a922e3 - Wrap the upstream method instead
- da401190 - Revert
- 41555634 - Forgot the url
- 4e6241d0 - patch double fetch from php-cgi-wasm
- be1ecbba - stop double booting php in worker
- 117a7cb5 - Remove an error (params is not defined)
- 31a686a1 - Revert "Remove an error (params is not defined)"
- 94c9b7f1 - Revert "stop double booting php in worker"
Toggle commit list-
a765d7cb - 1 commit from branch
Please register or sign in to reply