diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-04-18 17:35:57 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-04-18 17:35:57 +0200 |
commit | 66caabb29d59d5722c709834789bb1afee1daf30 (patch) | |
tree | 802176961c6ed6e7c2568cf5acd5dc7c90f565b7 /js/src/Ice/browser/WSTransceiver.js | |
parent | Fixed Objective-C iOS build to always use the debug configuration to prevent ... (diff) | |
download | ice-66caabb29d59d5722c709834789bb1afee1daf30.tar.bz2 ice-66caabb29d59d5722c709834789bb1afee1daf30.tar.xz ice-66caabb29d59d5722c709834789bb1afee1daf30.zip |
Fixed ICE-7817 - Ice/timeout test failure
Diffstat (limited to 'js/src/Ice/browser/WSTransceiver.js')
-rw-r--r-- | js/src/Ice/browser/WSTransceiver.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/js/src/Ice/browser/WSTransceiver.js b/js/src/Ice/browser/WSTransceiver.js index c6ddcab409c..736a55c8680 100644 --- a/js/src/Ice/browser/WSTransceiver.js +++ b/js/src/Ice/browser/WSTransceiver.js @@ -22,6 +22,15 @@ Ice._ModuleRegistry.require(module, ]); const IceSSL = Ice._ModuleRegistry.module("IceSSL"); +// +// With Chrome we don't want to close the socket while connection is in progress, +// see comments on close implementation below. +// +// We need to check for Edge browser as it might include Chrome in its user agent. +// +const IsChrome = navigator.userAgent.indexOf("Edge/") === -1 && + navigator.userAgent.indexOf("Chrome/") !== -1; + const Debug = Ice.Debug; const ExUtil = Ice.ExUtil; const Network = Ice.Network; @@ -133,6 +142,23 @@ class WSTransceiver return; } + // + // With Chrome (in particular on macOS) calling close() while the websocket isn't + // connected yet doesn't abort the connection attempt, and might result in the + // connection being reused by a different web socket. + // + // To workaround this problem, we always wait for the socket to be connected or + // closed before closing the socket. + // + // NOTE: when this workaround is no longer necessary, don't forget removing the + // StateClosePending state. + // + if(IsChrome && this._fd.readyState === WebSocket.CONNECTING) + { + this._state = StateClosePending; + return; + } + Debug.assert(this._fd !== null); try { |