|
|
@@ -14,7 +14,6 @@ import SocketIoShim from './SocketIoShim'
|
|
|
|
|
|
let ConnectionManager
|
|
|
const ONEHOUR = 1000 * 60 * 60
|
|
|
-let transport = 'handshake'
|
|
|
|
|
|
export default (ConnectionManager = (function() {
|
|
|
ConnectionManager = class ConnectionManager {
|
|
|
@@ -32,7 +31,7 @@ export default (ConnectionManager = (function() {
|
|
|
this.prototype.MAX_RECONNECT_GRACEFULLY_INTERVAL = 45 * 1000
|
|
|
}
|
|
|
|
|
|
- constructor(ide, $scope, eventTracking) {
|
|
|
+ constructor(ide, $scope) {
|
|
|
this.ide = ide
|
|
|
this.$scope = $scope
|
|
|
this.wsUrl = ide.wsUrl || null // websocket url (if defined)
|
|
|
@@ -135,45 +134,6 @@ export default (ConnectionManager = (function() {
|
|
|
'force new connection': true
|
|
|
}
|
|
|
)
|
|
|
- const socket = this.ide.socket
|
|
|
- socket.on('error', reportTransportError)
|
|
|
- socket.on('connect_failed', reportTransportError)
|
|
|
- socket.on('connecting', name => {
|
|
|
- transport = name
|
|
|
- socket.removeListener('error', reportTransportError)
|
|
|
- socket.on('error', reportTransportError)
|
|
|
- })
|
|
|
- socket.on('connectionAccepted', () => {
|
|
|
- // we have reached the real-time layer. ignore errors from now on.
|
|
|
- socket.removeListener('error', reportTransportError)
|
|
|
- socket.removeListener('connect_failed', reportTransportError)
|
|
|
- })
|
|
|
- function reportTransportError(error) {
|
|
|
- socket.removeListener('error', reportTransportError)
|
|
|
- socket.removeListener('connect_failed', reportTransportError)
|
|
|
- if (typeof error === 'undefined') {
|
|
|
- error = 'undefined'
|
|
|
- } else if (typeof error !== 'string') {
|
|
|
- try {
|
|
|
- error = JSON.stringify(error)
|
|
|
- } catch (e) {
|
|
|
- error = `JSON_serialize_failed: ${e.message}`
|
|
|
- }
|
|
|
- }
|
|
|
- if (transport === 'websocket' && error === '{"isTrusted":true}') {
|
|
|
- error = 'hidden'
|
|
|
- } else if (error.indexOf('<title>500') !== -1) {
|
|
|
- error = '500'
|
|
|
- } else if (error.indexOf('<title>502') !== -1) {
|
|
|
- error = '502'
|
|
|
- } else if (error.indexOf('<title>503') !== -1) {
|
|
|
- error = '503'
|
|
|
- } else if (error.length > 97) {
|
|
|
- error = error.slice(0, 97) + '...'
|
|
|
- }
|
|
|
- eventTracking.sendMBSampled('socket-io-error', { transport, error })
|
|
|
- }
|
|
|
- this.ide.socket.reportTransportError = reportTransportError
|
|
|
|
|
|
// handle network-level websocket errors (e.g. failed dns lookups)
|
|
|
|
|
|
@@ -611,10 +571,6 @@ Something went wrong connecting to your project. Please refresh if this continue
|
|
|
}
|
|
|
this.ide.socket.on('error', handleFailure)
|
|
|
this.ide.socket.on('connect', handleSuccess)
|
|
|
- const reportTransportError = this.ide.socket.reportTransportError
|
|
|
- this.ide.socket.on('error', reportTransportError)
|
|
|
- this.ide.socket.on('connect_failed', reportTransportError)
|
|
|
- transport = 'handshake'
|
|
|
|
|
|
// use socket.io connect() here to make a single attempt, the
|
|
|
// reconnect() method makes multiple attempts
|