-
Notifications
You must be signed in to change notification settings - Fork 313
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
Service Worker makes AJAX Progress Listener not Working #1141
Comments
This is about progress on an upload body, right? The progress may not be right if the service worker script clones or reads the FetchEvent.request's body. Are you doing that? Can you post your fetch event handler? Besides that, I am willing to bet service worker implementations have bugs related to this. In gecko I am fairly sure we don't pipe back progress from the network socket, through the SW, back to the original XHR. In theory this could be possible if you do a pass-through like |
In gecko I think progress should work if you avoid calling respondWith() for these requests in your service worker. |
Hi wanderview, thanks for the answer. Yeah, I think I know the answer. It is because of the fetch API in my SW. service-worker.js (Fetch Section)
Here's a reference: JakeChampion/fetch#89 |
@albertsylvester Since Cache API never stores "POST" requests, you could put this at the top of your fetch event handler to avoid the respondWith():
I'm not sure we can make the pass-through |
Thanks @wanderview. You are awesome. Why do you want to avoid respondWith()? |
It allows the network request to complete just like it would without the service worker (in theory). |
Sorry, I think maybe we should keep this open to track the problem with progress when using a pass-through service worker. |
Ok @wanderview . Thanks |
@wanderview which part of the spec is causing this to break currently? |
Uh, fetch API doesn't have any progress API yet? Don't we need FetchObserver for that? Until we have that we can't really propagate progress through the respondWith() accurately. The best you can do is use a ReadableStream for the upload and assume when its read its been uploaded, but re-buffering can be taking place. |
I thought, because of the way the stream was adopted, https://fetch.spec.whatwg.org/#concept-body-transmitted would still update, but I need to take a closer look. Fetch observing would certainly make this clearer. |
I wasn't aware of the "transmitted bytes" language in fetch upload stream spec. I guess it might be adequate for the progress issue, but it also kind of seems like a de-opt for upload throughput to me. It doesn't really match actual browser implementation (at least ours) very well. |
@jakearchibald would it be possible to create a polyfill using the stream object for upload progress within/for the Fetch API ?? From this: https://github.com/yutakahirano/fetch-with-streams/ It seems a bit complicated |
Hi everyone,
With Service Worker (SW) installed on a web apps, it caused "AJAX Progress Listener" not working.
Any idea?
Tested in Chrome Desktop, Chrome Mobile v 58.0, Firefox Desktop v 52.0.2, Firefox Android v 53.0.2
It's working
Thanks in advance
The Service Worker
And, the Ajax Uploader
The text was updated successfully, but these errors were encountered: