Skip to content

Commit

Permalink
Send correct status when info call fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jijojames18 authored and auvipy committed Sep 18, 2023
1 parent 2011ab1 commit 0b2eefe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/info-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function InfoAjax(url, AjaxObject) {
info = {};
}
}
self.emit('finish', info, rtt);
self.emit('finish', info, rtt, status);
self.removeAllListeners();
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/info-receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ InfoReceiver.prototype.doXhr = function(baseUrl, urlInfo) {
self.emit('finish');
}, InfoReceiver.timeout);

this.xo.once('finish', function(info, rtt) {
this.xo.once('finish', function(info, rtt, status) {
debug('finish', info, rtt);
self._cleanup(true);
self.emit('finish', info, rtt);
self.emit('finish', info, rtt, status);
});
};

Expand Down
4 changes: 2 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ SockJS.OPEN = 1;
SockJS.CLOSING = 2;
SockJS.CLOSED = 3;

SockJS.prototype._receiveInfo = function(info, rtt) {
SockJS.prototype._receiveInfo = function(info, rtt, status) {
debug('_receiveInfo', rtt);
this._ir = null;
if (!info) {
this._close(1002, 'Cannot connect to server');
this._close(status || 1002, 'Cannot connect to server');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/end-to-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('End to End', function () {
}

try {
expect(e.code).to.equal(1002);
expect(e.code).to.equal(404);
expect(e.reason).to.equal('Cannot connect to server');
expect(e.wasClean).to.equal(false);
} catch (err) {
Expand Down

0 comments on commit 0b2eefe

Please sign in to comment.