mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-28 02:47:31 +00:00
fix: add more logs do collaborator doc saving (#8721)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
This commit is contained in:
parent
91eb4be23d
commit
9efefe3693
@ -40,7 +40,12 @@ export class AuthenticationExtension implements Extension {
|
||||
const token = decodeToken(data.token)
|
||||
const readonly = isGuest(token)
|
||||
|
||||
ctx.info('authenticate', { workspaceId, mode: token.extra?.mode ?? '', readonly })
|
||||
ctx.info('authenticate', {
|
||||
workspaceId,
|
||||
account: token.account,
|
||||
mode: token.extra?.mode ?? '',
|
||||
readonly
|
||||
})
|
||||
|
||||
if (readonly) {
|
||||
data.connection.readOnly = true
|
||||
|
@ -43,7 +43,7 @@ type ConnectionId = string
|
||||
|
||||
interface DocumentUpdates {
|
||||
context: Context
|
||||
collaborators: Set<ConnectionId>
|
||||
collaborators: Map<ConnectionId, number>
|
||||
}
|
||||
|
||||
export class StorageExtension implements Extension {
|
||||
@ -55,16 +55,21 @@ export class StorageExtension implements Extension {
|
||||
this.configuration = configuration
|
||||
}
|
||||
|
||||
async onChange ({ context, documentName }: withContext<onChangePayload>): Promise<any> {
|
||||
async onChange ({ context, document, documentName }: withContext<onChangePayload>): Promise<any> {
|
||||
const { connectionId } = context
|
||||
|
||||
if (document.isLoading) {
|
||||
console.warn('document changed while is loading', { documentName, connectionId })
|
||||
return
|
||||
}
|
||||
|
||||
const updates = this.updates.get(documentName)
|
||||
if (updates === undefined) {
|
||||
const collaborators = new Set([connectionId])
|
||||
const collaborators = new Map([[connectionId, Date.now()]])
|
||||
this.updates.set(documentName, { context, collaborators })
|
||||
} else {
|
||||
updates.context = context
|
||||
updates.collaborators.add(connectionId)
|
||||
updates.collaborators.set(connectionId, Date.now())
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,15 +97,17 @@ export class StorageExtension implements Extension {
|
||||
const { ctx } = this.configuration
|
||||
const { connectionId } = context
|
||||
|
||||
ctx.info('store document', { documentName, connectionId })
|
||||
|
||||
const updates = this.updates.get(documentName)
|
||||
const connections = document.getConnectionsCount()
|
||||
const collaborators = updates?.collaborators.size ?? 0
|
||||
ctx.info('store document', { documentName, connectionId, connections, collaborators })
|
||||
|
||||
if (updates === undefined || updates.collaborators.size === 0) {
|
||||
ctx.info('no changes for document', { documentName, connectionId })
|
||||
return
|
||||
}
|
||||
|
||||
updates.collaborators = new Set()
|
||||
updates.collaborators.clear()
|
||||
await this.storeDocument(documentName, document, updates.context)
|
||||
}
|
||||
|
||||
@ -114,16 +121,23 @@ export class StorageExtension implements Extension {
|
||||
const { ctx } = this.configuration
|
||||
const { connectionId } = context
|
||||
|
||||
const params = { documentName, connectionId, connections: document.getConnectionsCount() }
|
||||
ctx.info('disconnect from document', params)
|
||||
|
||||
const updates = this.updates.get(documentName)
|
||||
const connections = document.getConnectionsCount()
|
||||
const collaborators = updates?.collaborators.size ?? 0
|
||||
const updatedAt = updates?.collaborators.get(connectionId)
|
||||
ctx.info('disconnect from document', { documentName, connectionId, connections, collaborators, updatedAt })
|
||||
|
||||
if (updates === undefined || !updates.collaborators.has(connectionId)) {
|
||||
ctx.info('no changes for document', { documentName, connectionId })
|
||||
return
|
||||
}
|
||||
|
||||
updates.collaborators = new Set()
|
||||
if (document.isLoading) {
|
||||
ctx.warn('document is loading', { documentName, connectionId })
|
||||
return
|
||||
}
|
||||
|
||||
updates.collaborators.clear()
|
||||
await this.storeDocument(documentName, document, context)
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ export class PlatformStorageAdapter implements CollabStorageAdapter {
|
||||
})
|
||||
|
||||
if (ydoc !== undefined) {
|
||||
ctx.info('loaded from storage', { documentName })
|
||||
return ydoc
|
||||
}
|
||||
} catch (err: any) {
|
||||
@ -69,6 +70,7 @@ export class PlatformStorageAdapter implements CollabStorageAdapter {
|
||||
// it to ensure the next time we load it from the ydoc document
|
||||
await saveCollabYdoc(ctx, this.storage, wsIds, documentId, ydoc)
|
||||
|
||||
ctx.info('loaded from initial content', { documentName, content })
|
||||
return ydoc
|
||||
}
|
||||
} catch (err: any) {
|
||||
|
Loading…
Reference in New Issue
Block a user