Giter VIP home page Giter VIP logo

Comments (18)

foolip avatar foolip commented on May 27, 2024 1

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.

vandys avatar vandys commented on May 27, 2024 1

With cancellation and timeouts (still) missing from fetch, would it be appropriate to revisit
access to XMLHttpRequest in Service Workers?

from xhr.

vandys avatar vandys commented on May 27, 2024 1

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.

annevk avatar annevk commented on May 27, 2024

So the idea is to not expose XMLHttpRequest in new contexts in order to encourage usage of fetch()... Seems okay I guess.

from xhr.

tyoshino avatar tyoshino commented on May 27, 2024

Sounds good

from xhr.

tyoshino avatar tyoshino commented on May 27, 2024

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.

annevk avatar annevk commented on May 27, 2024

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.

foolip avatar foolip commented on May 27, 2024

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.

dominiccooney avatar dominiccooney commented on May 27, 2024

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.

annevk avatar annevk commented on May 27, 2024

Ping!

from xhr.

foolip avatar foolip commented on May 27, 2024

Ping again @coonsta, what do you think we should do here?

from xhr.

kinu avatar kinu commented on May 27, 2024

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.

mfalken avatar mfalken commented on May 27, 2024

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.

foolip avatar foolip commented on May 27, 2024

OK, so I guess let's change the spec instead.

from xhr.

annevk avatar annevk commented on May 27, 2024

Thank you folks!

from xhr.

wanderview avatar wanderview commented on May 27, 2024

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.

CyrilCommando avatar CyrilCommando commented on May 27, 2024

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.

annevk avatar annevk commented on May 27, 2024

Well, we also want folks to move to fetch(). That started in 2015 and is especially true today.

from xhr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.