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

Use Raynos/xhr for XMLHttpRequests #2318

Closed
wants to merge 1 commit into from
Closed

Conversation

dmlap
Copy link
Member

@dmlap dmlap commented Jul 7, 2015

Get rid of our custom XHR shim. Export it as videojs.xhr.

Get rid of our custom XHR shim. Export it as videojs.xhr.
@@ -249,7 +249,7 @@ var parseCues = function(srcContent, track) {
};

var loadTrack = function(src, track) {
XHR(src, Fn.bind(this, function(err, response, responseBody){
XHR({ uri: src }, Fn.bind(this, function(err, response, responseBody){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I believe xhr does this for us already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it does. I'm not unhappy with this version though. You?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with either.

@gkatsev
Copy link
Member

gkatsev commented Jul 7, 2015

LGTM

@dmlap
Copy link
Member Author

dmlap commented Jul 7, 2015

Raynos/xhr is incompatible with sinon because it captures a reference to window.XHR on module load. We use fakeXHR in a bunch of projects for testing purposes. It would be a real pain to have to find an alternate solution for testing.

@dmlap
Copy link
Member Author

dmlap commented Jul 8, 2015

This shouldn't be pulled in unless naugtur/xhr#80 gets merged and released.

dmlap added a commit to dmlap/video.js that referenced this pull request Jul 8, 2015
While we wait for Raynos/xhr to allow for downstream testing, expose our own XHR shim. An alternative to videojs#2318.
@dmlap dmlap mentioned this pull request Jul 8, 2015
@heff
Copy link
Member

heff commented Jul 15, 2015

The XHR update has been merged but not released. Can we point to master for now?

@dmlap
Copy link
Member Author

dmlap commented Jul 20, 2015

Another shortcoming: it doesn't seem possible to distinguish between request timeout errors and other failure conditions. HLS has different behavior for requests timeouts (aggressively downshifting quality) versus other errors (move along to the next segment). We would have trouble adopting Raynos/xhr until it was possible to distinguish between the two.

@heff
Copy link
Member

heff commented Jul 20, 2015

Ugh. Want to submit an issue? Maybe there's a way of discovering that we're not aware of.

@gkatsev
Copy link
Member

gkatsev commented Jul 20, 2015

nope, there's no good way of figuring it out. It just returns an error with "unknown" as the message.

@heff
Copy link
Member

heff commented Jul 20, 2015

We can't use the response status code, or lack of, or anything that knows xhr.abort('timeout') happened? If there's nothing it seems like it's at least worth submitting an issue about.

@dmlap
Copy link
Member Author

dmlap commented Jul 21, 2015

Closing in favor of exposing our internal helper for now.

@dmlap dmlap closed this Jul 21, 2015
@heff
Copy link
Member

heff commented Jul 21, 2015

Opened naugtur/xhr#88 despite the naysayers

dmlap added a commit to dmlap/video.js that referenced this pull request Jul 21, 2015
While we wait for Raynos/xhr to allow for downstream testing, expose our own XHR shim. An alternative to videojs#2318.
@naugtur
Copy link

naugtur commented Jul 22, 2015

All latest changes are published as xhr@2.0.3
It's now possible to override XMLHttpRequest used by xhr at any point in time. (see readme)

If you want to have separate handling for timeout in browsers that support it correctly, it's actually possible ever since 1.something.
Pass a beforeSend function that sets xhrobj.timeout and xhrobj.ontimeout instead of using options.timeout. We are handling timeouts with our own timer, because of some browsers, but there's nothing stopping you from using the XHR timeout feature directly.

We'll see if there's a reason to get naugtur/xhr#88 implemented, but I need more context.

@heff
Copy link
Member

heff commented Sep 3, 2015

Reopening at least as a placeholder, since it looks like we can get this in for 5.0.

@heff heff reopened this Sep 3, 2015
@heff heff added this to the v5.0.0 milestone Sep 3, 2015
@heff
Copy link
Member

heff commented Sep 10, 2015

@dmlap I know there's an open issue around this, but if the verdict is we can make this work as is for HLS, I'm gonna go ahead and pull this in to get this closed down. Any objection?

@dmlap
Copy link
Member Author

dmlap commented Sep 11, 2015

No, we can't get this working as-is for HLS. It sounds like there is a good possibility that will change soon but it's not ready yet.

@heff
Copy link
Member

heff commented Sep 12, 2015

Ok sorry, I thought there was just a nice to have left. Moving to 5.1, and we'll see where it gets in the next week.

@heff heff modified the milestones: v5.1.0, v5.0.0 Sep 12, 2015
@naugtur
Copy link

naugtur commented Sep 12, 2015

Hi, I'm back from vacation. Check out naugtur/xhr#92 in case you want to share feedback before I release it.

heff pushed a commit to heff/video.js that referenced this pull request Sep 15, 2015
- Get rid of our custom XHR shim. Export it as videojs.xhr.
- Updated XHR to be stubbed everywhere in tests to prevent errors.
- Added npm install to the review process

closes videojs#2318
closes videojs#2594
@heff heff closed this in #2594 Sep 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants