Просмотр исходного кода

Merge pull request #2735 from overleaf/jpa-try-ws-fallback-on-missing-js

[frontend] ConnectionManager: use fallback backend on missing js blob

GitOrigin-RevId: cd5acf17c67d7fd94641411842f31a17942f1385
Timothée Alby 6 лет назад
Родитель
Сommit
e3bd6951cf
1 измененных файлов с 5 добавлено и 0 удалено
  1. 5 0
      services/web/frontend/js/ide/connection/ConnectionManager.js

+ 5 - 0
services/web/frontend/js/ide/connection/ConnectionManager.js

@@ -35,6 +35,11 @@ define([], function() {
         this.$scope = $scope
         this.$scope = $scope
         this.wsUrl = ide.wsUrl || null // websocket url (if defined)
         this.wsUrl = ide.wsUrl || null // websocket url (if defined)
         if (typeof io === 'undefined' || io === null) {
         if (typeof io === 'undefined' || io === null) {
+          if (this.wsUrl && !window.location.href.match(/ws=fallback/)) {
+            // if we tried to boot from a custom real-time backend and failed,
+            // try reloading and falling back to the siteUrl
+            window.location = window.location.href + '?ws=fallback'
+          }
           console.error(
           console.error(
             'Socket.io javascript not loaded. Please check that the real-time service is running and accessible.'
             'Socket.io javascript not loaded. Please check that the real-time service is running and accessible.'
           )
           )