Skip to content

Commit

Permalink
Fixes #1 - Handle request error events.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbordet committed Apr 10, 2017
1 parent 7aa358a commit 53b5afd
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions cometd-nodejs-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,13 @@ module.exports = {
}
});
});
_request.on('abort', function() {
self.readyState = window.XMLHttpRequest.DONE;
if (self.onerror) {
self.onerror();
}
});
_request.on('aborted', function() {
self.readyState = window.XMLHttpRequest.DONE;
if (self.onerror) {
self.onerror();
}
['abort', 'aborted', 'error'].forEach(function(event) {
_request.on(event, function() {
self.readyState = window.XMLHttpRequest.DONE;
if (self.onerror) {
self.onerror();
}
});
});
if (data) {
_request.write(data);
Expand Down

0 comments on commit 53b5afd

Please sign in to comment.