UBERF-8899: Fix Reconnect performance (#7597)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2025-01-07 23:21:27 +07:00
committed by GitHub
parent 1d836b73ab
commit a2cbc2a5fb
12 changed files with 106 additions and 73 deletions
+1
View File
@@ -115,6 +115,7 @@ export class ModelMiddleware extends BaseMiddleware implements Middleware {
private setLastHash (hash: string): void {
this.lastHash = hash
this.context.lastHash = this.lastHash
this.lastHashResponse = Promise.resolve({
full: false,
hash,
+21 -1
View File
@@ -16,12 +16,16 @@
import core, {
DOMAIN_TRANSIENT,
DOMAIN_TX,
generateId,
TxProcessor,
WorkspaceEvent,
type Doc,
type MeasureContext,
type SessionData,
type Tx,
type TxCUD,
type TxResult
type TxResult,
type TxWorkspaceEvent
} from '@hcengineering/core'
import { PlatformError, unknownError } from '@hcengineering/platform'
import type { DBAdapterManager, Middleware, PipelineContext, TxMiddlewareResult } from '@hcengineering/server-core'
@@ -68,6 +72,22 @@ export class TxMiddleware extends BaseMiddleware implements Middleware {
txes: Array.from(new Set(txToStore.map((it) => it._class)))
}
)
// We need to remember last Tx Id in context, so it will be used during reconnect to track a requirement for refresh.
this.context.lastTx = txToStore[txToStore.length - 1]._id
// We need to deliver information to all clients so far.
const evt: TxWorkspaceEvent = {
_class: core.class.TxWorkspaceEvent,
_id: generateId(),
event: WorkspaceEvent.LastTx,
modifiedBy: core.account.System,
modifiedOn: Date.now(),
objectSpace: core.space.DerivedTx,
space: core.space.DerivedTx,
params: {
lastTx: this.context.lastTx
}
}
;(ctx.contextData as SessionData).broadcast.txes.push(evt)
}
if (txPromise !== undefined) {
await txPromise