Comments (18)
I was half expecting push back on this. Won't it be annoying that you can't reuse some existing library code because it uses XHR? From https://code.google.com/p/chromium/issues/detail?id=395931 it sounds like part of the motivation was to get rid of the sync mode, but is that a bigger problem for service workers than other kinds of workers?
from xhr.
With cancellation and timeouts (still) missing from fetch, would it be appropriate to revisit
access to XMLHttpRequest in Service Workers?
from xhr.
Well, we also want folks to move to
fetch()
. That started in 2015 and is especially true today.
fetch() eventually added an abort, but you still have to cobble together your own timeout. And the abort is quite a bit clunkier than what it takes for an XHR. I hope in the future you'll make sure your API's are a superset (and preferably cleaner) before forcing the sunset of old API's.
from xhr.
So the idea is to not expose XMLHttpRequest in new contexts in order to encourage usage of fetch()
... Seems okay I guess.
from xhr.
Sounds good
from xhr.
The pain in implementation would be small if we're to keep only async XHR, I guess. Not sure if there're works such that:
- it makes sense to get the works done in SW, and
- (part of) the works don't require the Fetch API's functionality, and
- complicated so that use of library makes sense
from xhr.
I was actually expecting us to simply forbid synchronous XMLHttpRequest in SW, but leave it working otherwise. However, since fetch()
shipped relatively quickly I guess I do not really care either way. If there is some kind of win in not exposing it (or maybe there is one down the line) I would be cool with that.
What about ProgressEvent
?
from xhr.
Actually ProgressEvent
is exposed only on Window
in Blink, but I believe that's an oversight. I think the spec should expose all the interfaces in the same contexts and Blink should change.
To me, throwing InvalidAccessError
when sync XHR is attempted in any non-whitelisted context sounds pretty good. Which kinds of workers already depend on sync XHR I don't know, but we could measure it.
@coonsta and @jakearchibald, thoughts?
from xhr.
I'm sorry that we didn't file a spec bug and link to it from that patch; we should always do that. @slightlyoff is a better person to ask about exposing XHR; @kinu is a better person to ask for implementer feedback from Chromium/Blink.
from xhr.
Ping!
from xhr.
Ping again @coonsta, what do you think we should do here?
from xhr.
Only shipping async XHR in SW makes sense to me and I don't feel it's too difficult to implement in Chromium/Blink. I'm not really sure if exposing XHR is still awaited since SW was shipped without XHR sometime ago and now we have fetch, but having it may make it easier to use JS libraries in SW I guess.
/cc @mattto
from xhr.
I haven't heard users complain about lack of XHR in Chrome's SW implementation yet, so maybe there's no need to add async XHR now. We can always add it later if needed.
from xhr.
OK, so I guess let's change the spec instead.
from xhr.
Thank you folks!
from xhr.
With cancellation and timeouts (still) missing from fetch, would it be appropriate to revisit
access to XMLHttpRequest in Service Workers?
Cancellation is making progress. We have experimental support for it in FF55 if you set dom.fetchController.enabled to true.
https://twitter.com/wanderview/status/844924163634679808
from xhr.
Let me get this straight - The option to use XHR in service workers was removed because one guy thinks it's "redundant", and is partial to fetch?
Options be damned!
from xhr.
Well, we also want folks to move to fetch()
. That started in 2015 and is especially true today.
from xhr.
Related Issues (20)
- Expose ProgressEvent to ServiceWorker HOT 14
- Handle error while reading response body in synchronous XHR HOT 1
- Reference primitive for "If one or more event listeners are registered"
- Spec requires firing at least two "progress" events; browsers do not. HOT 1
- features request:add SynXMLHttpRequest for Avoid Callback Hell Programming HOT 1
- Why do we need to remove synchronous XHR? HOT 2
- link error breaking deploys HOT 2
- Allow to send body within GET http requests HOT 1
- Aborted flag check in "handle errors" HOT 2
- interop: blob with empty content type is not converted to text/xml HOT 3
- Wrong upload progress when network interrupts HOT 3
- xmlhttprequest.responseText occasionally appears Chinese garbled characters HOT 1
- XHR: how can I read request headers? HOT 1
- Need Discussion of 'why' Behind Deprecation of sync xhr HOT 2
- Wrong algorithm + missing realm argument when creating ArrayBuffer
- Ambiguous definition/initial values of network error HOT 3
- Use HTML's parse a URL HOT 2
- FormData & submitter[formaction] HOT 6
- `FormData`: Accept `object` form in constructor HOT 1
- Clarify if `ProgressEvent.loaded` should indicate the size of compress, or uncompressed, data HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xhr.