Fixes #10555 Invalid State Error (INVALID_STATE_ERR)

- Instead of throwing error on _didClose when the state is invalid just sends a message to console
- includes the readyState in the log
This commit is contained in:
filipenevola
2020-07-17 13:21:20 -04:00
parent a9983a2aad
commit fe375da97b
2 changed files with 11 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
Package.describe({
name: "socket-stream-client",
version: "0.3.0",
version: "0.3.1",
summary: "Provides the ClientStream abstraction used by ddp-client",
documentation: "README.md"
});

View File

@@ -298,6 +298,12 @@ utils.log = function() {
}
};
utils.debug = function() {
if (_window.console && console.debug && console.debug.apply) {
console.debug.apply(console, arguments);
}
};
utils.bind = function(fun, that) {
if (fun.bind) {
return fun.bind(that);
@@ -1083,8 +1089,10 @@ SockJS.prototype._didClose = function(code, reason, force) {
var that = this;
if (that.readyState !== SockJS.CONNECTING &&
that.readyState !== SockJS.OPEN &&
that.readyState !== SockJS.CLOSING)
throw new Error('INVALID_STATE_ERR');
that.readyState !== SockJS.CLOSING) {
utils.debug('INVALID_STATE_ERR', that.readyState);
return;
}
if (that._ir) {
that._ir.nuke();
that._ir = null;