From fe375da97b341dffdd8c55a34e02605d9febcf75 Mon Sep 17 00:00:00 2001 From: filipenevola Date: Fri, 17 Jul 2020 13:21:20 -0400 Subject: [PATCH] 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 --- packages/socket-stream-client/package.js | 2 +- packages/socket-stream-client/sockjs-0.3.4.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/socket-stream-client/package.js b/packages/socket-stream-client/package.js index e7cf7d1831..ddf6058104 100644 --- a/packages/socket-stream-client/package.js +++ b/packages/socket-stream-client/package.js @@ -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" }); diff --git a/packages/socket-stream-client/sockjs-0.3.4.js b/packages/socket-stream-client/sockjs-0.3.4.js index 2952cdf39b..f4bc6ac399 100644 --- a/packages/socket-stream-client/sockjs-0.3.4.js +++ b/packages/socket-stream-client/sockjs-0.3.4.js @@ -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;