-
Notifications
You must be signed in to change notification settings - Fork 96
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
ECONNRESET err.code for abort() #93
Comments
Yes, please! I get quite a bit of 'Internal XMLHttpRequest Error' entries in our error-logging due to aborting requests on purpose :( |
This seems very related to #104. These issues could probably be merged once we decide what |
To emulate node (https://github.com/request/request to be precise) it would require to skip calling the callback at all, as in https://github.com/Raynos/xhr/tree/abort-timeout Any feedback on that? |
Requesting feedback ;) |
I haven't poked at |
#104 is fixed, this should not be an issue anymore. |
I am running into an issue here where if I call test("aborting XHR prevents callback from being called", { timeout: 500 }, function(assert) {
var req = xhr({ uri: "/mock/200ok" }, function(err, response) {
assert.fail('this callback should not be called');
});
req.abort();
assert.end()
}) AFAICT, Is there anything I'm missing here? I'd be happy to take a crack at a PR if I can figure out a good approach to fixing this. |
I can make the test above pass with the following code modification, pushing the function readystatechange() {
if (xhr.readyState === 4) {
setTimeout(loadFunc, 0)
}
} Any thoughts on this approach? |
(I don't think I have GH permissions or I would re-open this issue 😄 ) |
The issue was about something else and I'd rather you created a new one, but there's valuable content here now and I came too late, so there you go. Please create the PR and I'll get to it on Monday to check if it's the way to go. I'm not yet sure if the new behavior is better than the current one for everybody. |
Ok cool, I will PR this, thanks @naugtur. Also I'm happy to open a separate issue if that's more useful to you...LMK. |
Currently you can abort requests like so:
However, it just passes
err
as "Internal XMLHttpRequest Error" which makes it hard to distinguish between user-initiated cancellation and actual XHR errors.If possible, it would be nice to emulate Node and use
ECONNRESET
forerr.code
when the error is due to anabort()
rather than, say, a connection or JSON parse error. This way abstractions like xhr-request that work in Node/Browser could both use the same logic for handlingreq.abort()
.The text was updated successfully, but these errors were encountered: