Closed
Description
I'm submitting a...
[x] Feature request
Current behavior
ServiceWorker breaks AJAX uploads progress reporting.
Expected behavior
AJAX upload progress listener should work.
What is the motivation / use case for changing the behavior?
Progress is needed when handling uploads.
There is an open issue here and it is on this w3c roadmap
Until then, as far as I could read, it would be possible to make this work by checking the event.request.url
at the very top of the SW script and simply return
if it matches certain urls that would be specified in ngsw-config.json
Environment
Angular version: 5.1.2
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
doronsever commentedon Jan 21, 2018
We have the same problem either.
For now, we added an ugly spinner instead of a progress bar but our clients aren't happy with it.
It would be best if this topic can be priorities somehow
NgxDev commentedon Jan 24, 2018
@doronsever
In case this is critical for you, I've just tested with editing the resulted
ngsw-worker.js
file and it works:I've installed
gulp
andgulp-replace
😬 and created a gulp task that replacesonFetch(event) {
with:in the
dist/ngsw-worker.js
file and then my build script becameng build [whatever options I have] && gulp swAjaxUploadFix
(or I could have used the default task and simply rungulp
, but I like to name my tasks).Of course, in my case we have the convention that all upload urls contain
/upload
.And also I log a big, multiple line message in the console on build so I don't forget about removing this workaround as soon as this feature gets implemented by the Angular team.
But, meanwhile, reporting the progress on uploads works! 😁
So, I just wanted to let you know it works. Because when I posted the issue, I had only read that this would fix progress reporting, and took what I read for granted, haven't tested myself. Now I have!
doronsever commentedon Jan 24, 2018
@MrCroft Thank you very much!
At least it's working now :)
ganeshkbhat commentedon May 5, 2018
Can this actually be put as a feature request from my end also? I think something having a key like
"exclude"
with interface likeinterface Exclude { name: string; urls: string[]; version?: number; }
. There is one more open question like this in 'so. https://stackoverflow.com/questions/47693093/angular-5-and-service-worker-how-to-exclude-a-particular-path-from-ngsw-configgkalpak commentedon May 5, 2018
The only problem I see is that the check should happen asynchronously. Based on #23025 (comment) it shouldn't be possible to decide whether to handle the request or not asycnhronously. But I am wondering if calling
event.waitUntil()
allows us to defer the decision of whether to callevent.respondWith()
or not and still be able to choose not to handle the request.I.e. something like:
ganeshkbhat commentedon May 18, 2018
I see the point. If thats the case it definitely seems like its a tradeoff on performance and feature. May be someone is is more aware than me on the implementation can point the way forward.
[-][ServiceWorker] Possibility to have urls that bypass the ServiceWorker (otherwise, Ajax progress listener doesn't work)[/-][+]feat(service-worker): Support ignoring specific URLs (e.g. for AJAX progress listener, video streaming, range requests)[/+]gkalpak commentedon Sep 17, 2018
This would also be useful as a workaround for Firebase uploads (#23244), video streaming (#25007) and range requests (e.g. seeking in videos) (#25865).
A possible solution could come through #20756 (comment).
64 remaining items