mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 00:45:40 -05:00
Merge pull request #3146 from overleaf/jpa-revert-2938-jpa-simple-sampled-socket-io-error
Revert "[misc] emit 'socket-io-error' event on connection setup errors" GitOrigin-RevId: 784db67b33c882f2e06a0e0590e2333ed6986918
This commit is contained in:
parent
8a327c5692
commit
02d22bef00
2 changed files with 2 additions and 46 deletions
|
@ -180,7 +180,7 @@ App.controller('IdeController', function(
|
|||
ide.$scope = $scope
|
||||
|
||||
ide.referencesSearchManager = new ReferencesManager(ide, $scope)
|
||||
ide.connectionManager = new ConnectionManager(ide, $scope, eventTracking)
|
||||
ide.connectionManager = new ConnectionManager(ide, $scope)
|
||||
ide.fileTreeManager = new FileTreeManager(ide, $scope)
|
||||
ide.editorManager = new EditorManager(ide, $scope, localStorage)
|
||||
ide.onlineUsersManager = new OnlineUsersManager(ide, $scope)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue