-
Notifications
You must be signed in to change notification settings - Fork 28
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
Upgrade to xhr v2.0 #32
Comments
+1, i'd love to use |
I'd need input from contributors on how you want the choice between I make the choice like this: var requestEngine = require('request') package.json:
but that's not an option here, as browser is the default for backward-compatibility reasons. So the only option left is setting the |
what do you mean by this? another option is using nets, which takes the package.json browser field approach. |
I mean if you run browserify on code using ampersand-sync you shouldn't need to set anything up to get xhr as a dependency. So using the browser field in package.json to let user switch is not an option. Also, the switch to xhr 2 will not affect the API of sync. You don't have to update major version. |
Can I get input from maintainers on something? Should the 3rd argument to What are your thoughts? But if you are planning on releasing a new version |
Hey @naugtur, sorry for the delay in answering your questions. To answer one of them, yes we are planning a major version. The open issues for it are being tracked here https://github.com/AmpersandJS/ampersand-sync/milestones/v4.0 (and this issue is a part of it). For the others:
@naugtur If you want to work on a PR for this that would be great! It would probably be a good way to generate more discussion around some of the points raised here. |
rather than include configurable, I'd be tempted to pick a single library that does both. Perhaps https://www.npmjs.com/package/superagent ? |
though using superagent may require too much of an API change. I'm just a bit hesitant to include two disparate libraries and hope they keep their APIs in sync. |
I intend to implement the whole thing. I'm asking for more discussion so that I can implement something that's inline with your expectations. I am working on a PR, actually, I have the main change done, but I'd like to build a layer of integration tests for sync+xhrImplementation that could be run for both browser and node. That kind of test would be hugely beneficial to me right now as I'm wondering what can I break updating xhr. And if someone wishes to put anything else in place of xhr they can be sure it works. For node/browser switching I'm looking at the @HenrikJoreteg
When you develop with browserify, size matters ;) And Re: " I'm just a bit hesitant to include two disparate libraries and hope they keep their APIs in sync." |
I'm +1 on the points @naugtur raised and would also add that superagent currently has 125 open issues/PRs. That can be looked at a few different ways, but it does give me some hesitation about switching to it. |
TJ left the node community and all his projects had a hickup, hard to say how they're doing just by looking at the repo. I can guarantee support for xhr with my word ;) |
@naugtur @lukekarrys good enough for me, I'm a +1. Any other thoughts from @AmpersandJS/core-team? |
I know that @naugtur will take care of xhr in case anything changes, so I'm also +1 for this :) |
+1 on this, would help with serverside stuff. @naugtur what's the status of the implementation? I'm happy to give it a shot if you're busy? I tried just upgrading to xhr@2, and the tests pass, but not sure what to look for in more detail. Is there a summary of what's changed in 1->2? |
@latentflip I've been sick recently and I lagged. I can push what I already wrote to my fork, but there's the response format change involved and someone with more experience using ampersand state and models could try assessing the consequences. As for the tests - if I understood them correctly, current tests are stubbing the |
@naugtur yeah, that's what I was worried about with the tests. No pressure, just curious :) If you're up for pushing to a fork so I can take a look that'd be 👍 |
I pushed the minimal change required to work with xhr2 to https://github.com/naugtur/ampersand-sync and it's pretty trivial but, Instead of XMLHttpRequest it now passes a {
body: Object||String,
statusCode: Number,
method: String,
headers: {},
url: String,
rawRequest: xhr
} xhr1.x used to extend XMLHttpRequest with fields, but it was both: breaking older browsers and incompatible with If someone is calling methods on it or inspecting it for request headers to log them as error related data - it's going to break.
|
I'd say we do a major version bump. Versions are cheap. |
Though I'd add, that majoring ampersand-sync is annoying, so if we can avoid it let's do that, if not let's make sure we check other issues and roll any other stuff into it. |
In that case we need to sacrifice some of the browser support (breaking changes would remain in ie8/9 but nowhere else) to keep it backwards-compatible. But it means that the same code would work differently in ie8/9 than everywhere else. Doesn't sound like a good idea. On the other hand, xhr since something like 1.5 was only supporting old ies with this different response object (switched on by a certain option) so it was a pain in the a... already. You guys look around if you want to bump the version number and what to put there, I'll focus on integration tests for now. |
If mocky is easy and reliable I would start there, if it doesn't work out we can surely port to something else easy enough? Philip Roberts
|
Engine support is different than api support. This is a discussion we've had in the past and the last I heard it was something @HenrikJoreteg was going to ping the npm people about? |
@naugtur yeah, we can sort out versioning later. Let's just get it working the way we want to first. http://www.mocky.io/ sounds good to me. |
I've started testing how sync integrates with xhr. Line 195 in 74e311b
error was then asynchronously called after 404 came in, so if tests ran long enough, it would add a new t.end() to an ongoing test.
You can check out latest changes here: naugtur@bbdc412 (some comments there) I'll poke around how ajaxConfig passing works too, because something seems missing or broken there. BTW, why does it require underscore instead of using a selection of Amp? |
The underscore requirement is just old. We simply haven't swapped everything out yet. As a side note, much of my personal time to work on ampersand related stuff has been eaten up in the last month or so because i'm finishing up another project. I anticipate having more time to put into it personally in the coming weeks. |
Not sure where this attempt left off, but the ship is sailing on this. Rendr is now going to address the need to run Backbone on the client and server. I can't get either Render, Ampersand, or Backbone's
Just so people/search engines know, firing this up under node prior to xhr 2.0 yields
|
Well, I'm waiting for someone to take a look at my initial minor change and respond to some comments I made there. As far as I know the change is still going to happen, but no idea when. |
Sorry @naugtur which minor change is this? Is it in ampersand or xhr? |
and
The naugtur@bbdc412 link being the commit with comments I wanted to discuss. |
@bear have you seen mocky.io and do you have any thoughts about the comments in that link about in re having something useable for tests only during the tests vs something that's Just Available? |
Other than that one question that PR looks imminently mergeable. Really really great work there @naugtur I'm a big fan of the test refactor! |
Thanks @wraithgar |
We only claim IE9+ on ampersandjs.com so I don't foresee the IE8 support being any kind of a real sticking point. |
Can't we just document how to use an XHR polyfill on IE8, it is possible -- right? |
Well, the issue is, That's the shortest summary of the problem I'm capable of delivering ;) |
@wraithgar I love mocky.io because it allows tests to standup callbacks as needed |
Are we seriously holding up a release because an underlying version potentially adds support for an older browser that wasn't supported? This is not good practice. For a system that sells itself on modularity there are clear problems in the release structure. My advice would be to push out a release ASAP, we have 9 people participating in this report. Shy of that, my advice would be to follow the semvar suggestions.
We've got a bad case of indecision here, let's get this show on the road. Support for IE8 (a positive) is delaying me testing my amp.model in a headless system. Typically, we'd open up another bug for the new version talking about how to handle versions we don't want to support, right? That seems like a separate issue entirely (and, the way everyone handles that is to YMMV-it silently). |
IMHO what I proposed (28Feb) is ok, as it would be consistent across browsers and node, with rawRequest field containing the native XHR object in the browser. Since then I'm waiting for decisions I don't want to make as I'm not a maintainer. This thread seems to confirm that the integration tests I've written are ok. I'll just make a pull request and let you guys decide, ok? |
👍 I think that's a better start then waiting for months for more discussion about consistency with IE8. |
As a side node, I'm not 100% sure I opened this bug for related functionality in the right place, but we may want to examine it here to, and potentially also in the scope of xhr2.js |
Fixes #32, update to xhr2 with integration tests
xhr
is now fully compatible with a subset ofrequest
. Some bugs were eliminated.It would also make #21 much easier to implement - just by replacing
xhr
withrequest
. And with a minor setup the whole ampersand model would work in node.jsNow the http errors are treated as responses, so it's a change that requires a minor update to logic.
I'm planning to do a PR for that, but it'd be nice to open a conversation on that first.
The text was updated successfully, but these errors were encountered: