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

added request.setTimeout support #80

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

added request.setTimeout support #80

wants to merge 3 commits into from

Conversation

brandonrobertz
Copy link

This is a port of node's request http setTimeout method.

// set and handle the timeout signals on xhr
if (this.xhr) {
if (this.timeoutCb) {
this.xhr.ontimeout = this.timeoutCb;
Copy link
Member

Choose a reason for hiding this comment

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

Could be:

this.xhr.ontimeout = this.emit.bind(this, 'timeout')

Depends on whether you prefer anonymous closures though.

Copy link
Author

Choose a reason for hiding this comment

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

I pretty much ported directly from the node implementation, but used the xhr-provided timeout scaffolding. The this.once('timeout', callback) just adds a one-time event handler. It shouldn't call back immediately.

I'm gonna be doing a little more testing with your binding/emit code. It's a lot cleaner.

Copy link
Member

Choose a reason for hiding this comment

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

Right, sorry. My mistake. LGTM otherwise :)

@brandonrobertz
Copy link
Author

I've tested fa18e1f with my target libs. Looking good.

@dcousens
Copy link
Member

Could you add a basic test for this?
On 27 Jan 2015 2:45 pm, "B Roberts" [email protected] wrote:

I've tested fa18e1f
fa18e1f
with my target libs.


Reply to this email directly or view it on GitHub
#80 (comment)
.

@brandonrobertz
Copy link
Author

Yeah, I'll work on something. It's complicated, because so much of this depends on XMLHttpRequest. But it's worth it, so I'll see what I can put together. The existing tests mock out window with stubs, so I think I'll have to take a similar route with xhr.

@brandonrobertz
Copy link
Author

I wrote two tests. One to make sure request.setTimeout sets the correct xhr properties and another that simulates xhr timeout activity during send.

@brandonrobertz
Copy link
Author

If nobody objects or has comments ... @substack ?

@vvo
Copy link

vvo commented Mar 6, 2015

@substack any comments on this? thx

@connor4312
Copy link

Would it be possible to get this merged?

@vvo
Copy link

vvo commented Sep 26, 2016

I believe someone willing to do it would have to ask @substack on twitter for repository and maintainer rights on this project. If he feels like he will have the bandwidth and will to do so.

@brandonrobertz
Copy link
Author

I spoke with substack on IRC a while back about this and it turns out browserify is now using stream-http when you require('http'). So it looks like this codebase is deprecated?

@vvo
Copy link

vvo commented Sep 28, 2016

So it looks like this codebase is deprecated?

Yes if you are using the latest browserify. Some people may not but not sure we need to fix this :)

Then the next step would be to deprecate this module officially in the README, close issues and PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants