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

#89 improved for compatibility #92

Merged
merged 2 commits into from
Sep 14, 2015
Merged

#89 improved for compatibility #92

merged 2 commits into from
Sep 14, 2015

Conversation

naugtur
Copy link
Owner

@naugtur naugtur commented Sep 12, 2015

Merged #89 and added a way to distinguish timeout errors without parsing messages.
error.code is compatible with what https://github.com/request/request does

@mattdesl
Copy link

One more thing that might be nice is an error code for 'abort()'. Right now it's tricky to know whether the error was due to cancellation or something more serious.

It could be the same code used by 'http' abort()

@naugtur
Copy link
Owner Author

naugtur commented Sep 12, 2015

xhr only ever calls abort() when our manual timeout occurs, so the code is ETIMEDOUT;
we don't expose our own abort method to proxy the original one

Or did I misunderstand?

@heff
Copy link

heff commented Sep 12, 2015

@dmlap any feedback?

Looks good to me, thanks @naugtur!

@mattdesl
Copy link

@naugtur In all browsers, the following should be supported:

var req = xhr(url, (err, resp) => {
   // err will be "Internal XMLHttpRequest Error"
})

// when user cancels request
cancelButton.on('click', () => req.abort())

However, it's hard to distinguish between a cancel or another time of error.

I can open another issue if it's outside the scope of this fix.

@naugtur
Copy link
Owner Author

naugtur commented Sep 13, 2015

@mattdesl It's not related to this issue imho. Feel free to add a new issue for that. (although I don't see how it'd be possible for xhr to know that someone aborted the request; if you aborted it, you know you did)

@dmlap
Copy link
Contributor

dmlap commented Sep 14, 2015

@naugtur this looks perfect. Thank you!

naugtur added a commit that referenced this pull request Sep 14, 2015
@naugtur naugtur merged commit 7fd6764 into master Sep 14, 2015
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.

5 participants