[WebsocketController] use a new JoinLeaveEpochMismatchError

This commit is contained in:
Jakob Ackermann 2020-08-20 13:10:22 +01:00
parent 0462e3e437
commit 50140f785a
2 changed files with 13 additions and 2 deletions

View file

@ -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,

View file

@ -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.