-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fixed abort/error/loadend event firing, statusCode on error, exceptions #6
Conversation
…HTTP errors fire; now always throw new Error() instead of string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR and the great work! ❤️
I'd be happy to merge and release this after you look at the minor suggestions I made.
this.handleError = function(error) { | ||
this.status = 503; | ||
this.handleError = function(error, status) { | ||
this.status = +status || 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a +
in front of status
?
@@ -1,7 +1,7 @@ | |||
{ | |||
"name": "xmlhttprequest-ssl", | |||
"description": "XMLHttpRequest for Node", | |||
"version": "1.5.5", | |||
"version": "1.5.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion your changes will at least warrant a minor version bump. Technically it should even be a major, but I doubt anyone's really relying on the specific error type or 503 status code being returned. If you could change it to be 1.6.0
that'd be awesome!
I'll merge the PR and make the changes myself. I'll release version 1.6.0 when I'm done. |
Thanks, Michael!
FYI - the + in front of status is to coerce the status to a number in case
somebody passes in a string.
Wes
…On Wed, 31 Jul 2019 at 13:16, Michael de Wit ***@***.***> wrote:
Merged #6 <#6> into
master.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6?email_source=notifications&email_token=AABTIUEJA3GV4XYXWH2ENITQCHCF3A5CNFSM4IER3VSKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOSZYHVCA#event-2523953800>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABTIUG2V6HYN5LVP2HXTLLQCHCF3ANCNFSM4IER3VSA>
.
--
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
|
I had to look at this because my application was hanging indefinitely using this particular XHR lib -- I had a domain name spelled wrong, and neither the error() nor load() events were firing, so my Promise was never resolving nor rejecting.
This fix addresses that problem by correcting the firing order (and ability to fire) of load, loadend, abort and error events. It also fixes the mis-fire of abort in the current driverdan 1.8 (original repo) version of this code that re-presented itself when I fixed abort firing.
A few smaller fixes were made while debugging this; in particular, status is supposed to be zero when the error handler fires, but was set to 503. I left it at 503 for the extra-process request stuff since I didn't have time to give that enough thought.
Also, I made exceptions into instanceof Error so that stack traces work (already done in driverdan code), and I threw all the event firing once readyState=4 on the NodeJS event loop. I left the earlier events alone since putting everything on the event loop was causing firing order issues; no readyState transistions were firing until the readyState was 4. I expect this change will let multiple load/error/abort handlers which await other (non-xhr) events to interoperate better with no correctness impact.