Skip to content
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

Document service workers don't support upload progress for httpClient reportProgress #24683

Closed
epelc opened this issue Jun 27, 2018 · 10 comments
Closed
Labels
feature Issue that requests a new feature
Milestone

Comments

@epelc
Copy link
Contributor

epelc commented Jun 27, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

I believe service workers do not support reporting upload progress(download progress should work) since it basically acts as a proxy and converts all XMLHttpRequests to the fetch api. This should be documented to avoid confusion. I just spent several hours trying to figure out why upload progress doesn't work when you use service workers.

Some more info on why:

  • Service workers act as a proxy for all requests

  • Requests come in as XmlHttpRequest or fetch and are always sent out to your server as a fetch request.

  • This can't be changed since service workers only support using the newer fetch api

  • Fetch doesn't support upload progress(it's not in the spec yet)

“it [fetch] is currently lacking when it comes to request progression (not response progression).” https://fetch.spec.whatwg.org/#fetch-api

image
the first uses xhr(XMLHttpRequest) but goes out of the service worker as a fetch request which is why you can’t get upload progress info

Expected behavior

Basically the docs should state that reportProgress doesn't work when using a service worker due to fetch api limitations.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Documenting this would make using service workers less confusing. Without these docs you have to dig deep and understand/know about more internals for XmlHttpRequest, fetch, how service workers actually work, etc.

Environment


Angular version: X.Y.Z


Browser:
- [x] Chrome (desktop) Version 67.0.3396.87 (Official Build) (64-bit)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@epelc
Copy link
Contributor Author

epelc commented Jun 27, 2018

Here is the relevant feature spec that will add support fetch upload progress. It seems a ways off so docs would be good until then.

It's called FetchObserver
whatwg/fetch#607

@gkalpak gkalpak added comp: docs area: common/http area: service-worker Issues related to the @angular/service-worker package labels Jun 27, 2018
@ngbot ngbot bot added this to the needsTriage milestone Jun 27, 2018
@jenniferfell
Copy link
Contributor

@epelc Thanks for this research and clarification. I'm checking with engineering to ensure that they agree this is a useful/correct doc addition.

@alxhub
Copy link
Member

alxhub commented Sep 4, 2018

@jenniferfell this is a useful addition, albeit an esoteric one.

@alxhub alxhub removed area: common/http area: service-worker Issues related to the @angular/service-worker package labels Sep 4, 2018
@tzahari
Copy link

tzahari commented Sep 5, 2018

It would be great if there is a possibility to configure the http request or the service worker not to intercept specific requests. Like mention in the #25007
Then the progress listener would work again.

@oliverjanik
Copy link

Since when are file uploads esoteric? Browser and library authors need to treat file uploads as a first class citizen. Literally every line of business app has some form of attachment upload.

@Jun711
Copy link
Contributor

Jun711 commented Apr 2, 2019

@tzahari
For a temporary workaround, you can modify your ngsw-worker.js. Look for onFetch function, modify the function so that it stops executing when detecting your upload endpoint.

onFetch(event) {
  if (event.request.url.indexOf('upload') !== -1) {
    return;
  }
  ...
}

You can check out this article for more information.

@sachq
Copy link

sachq commented Apr 14, 2019

Is there any workaround other than modifying ngsw-worker.js?

Thanks.

@FreakTheMighty
Copy link

Should this be closed? It seems like #21191 resolves this issue.

@sachq

@epelc
Copy link
Contributor Author

epelc commented May 9, 2019

@FreakTheMighty thanks for the link. To be clear see the pr for that issue 6200732 There are now docs about setting a special header or other flags to bypass the service worker entirely for specific requests.

@epelc epelc closed this as completed May 9, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

10 participants