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

[WebsocketController] use a new JoinLeaveEpochMismatchError

Jakob Ackermann 6 лет назад
Родитель
Сommit
50140f785a

+ 7 - 0
services/real-time/app/js/Errors.js

@@ -38,6 +38,12 @@ class DocumentUpdaterRequestFailedError extends OError {
   }
 }
 
+class JoinLeaveEpochMismatchError extends OError {
+  constructor() {
+    super('joinLeaveEpoch mismatch')
+  }
+}
+
 class MissingSessionError extends OError {
   constructor() {
     super('could not look up session by key')
@@ -80,6 +86,7 @@ module.exports = {
   ClientRequestedMissingOpsError,
   DataTooLargeToParseError,
   DocumentUpdaterRequestFailedError,
+  JoinLeaveEpochMismatchError,
   MissingSessionError,
   NotAuthorizedError,
   NotJoinedError,

+ 6 - 2
services/real-time/app/js/WebsocketController.js

@@ -9,7 +9,11 @@ const DocumentUpdaterManager = require('./DocumentUpdaterManager')
 const ConnectedUsersManager = require('./ConnectedUsersManager')
 const WebsocketLoadBalancer = require('./WebsocketLoadBalancer')
 const RoomManager = require('./RoomManager')
-const { NotAuthorizedError, NotJoinedError } = require('./Errors')
+const {
+  JoinLeaveEpochMismatchError,
+  NotAuthorizedError,
+  NotJoinedError
+} = require('./Errors')
 
 let WebsocketController
 module.exports = WebsocketController = {
@@ -180,7 +184,7 @@ module.exports = WebsocketController = {
       }
       if (joinLeaveEpoch !== client.joinLeaveEpoch) {
         // another joinDoc or leaveDoc rpc overtook us
-        return callback(new Error('joinLeaveEpoch mismatch'))
+        return callback(new JoinLeaveEpochMismatchError())
       }
       // ensure the per-doc applied-ops channel is subscribed before sending the
       // doc to the client, so that no events are missed.