From e755207c3b9a1ba307ff0cf6bd7aafda67ed423f Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sun, 25 Jan 2026 14:01:32 +0000 Subject: [PATCH] debug logging --- .../extensions/redis-sync/collab-proxy-socket.ts | 8 ++++---- .../extensions/redis-sync/redis-sync.extension.ts | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/server/src/collaboration/extensions/redis-sync/collab-proxy-socket.ts b/apps/server/src/collaboration/extensions/redis-sync/collab-proxy-socket.ts index 2633fccf..32787f0a 100644 --- a/apps/server/src/collaboration/extensions/redis-sync/collab-proxy-socket.ts +++ b/apps/server/src/collaboration/extensions/redis-sync/collab-proxy-socket.ts @@ -8,11 +8,11 @@ import type { } from './redis-sync.types'; export class CollabProxySocket extends EventEmitter { - private replyTo: string; - private pongChannel: string; - private socketId: string; + private readonly replyTo: string; + private readonly pongChannel: string; + private readonly socketId: string; private pub: RedisClient; - private pack: Pack; + private readonly pack: Pack; readyState = 1; constructor( diff --git a/apps/server/src/collaboration/extensions/redis-sync/redis-sync.extension.ts b/apps/server/src/collaboration/extensions/redis-sync/redis-sync.extension.ts index fb01bb13..039f66b8 100644 --- a/apps/server/src/collaboration/extensions/redis-sync/redis-sync.extension.ts +++ b/apps/server/src/collaboration/extensions/redis-sync/redis-sync.extension.ts @@ -1,4 +1,4 @@ -// Source https://github.com/ueberdosis/hocuspocus/pull/1008 +// Adapted from https://github.com/ueberdosis/hocuspocus/pull/1008 - MIT import type { IncomingMessage } from 'node:http'; import { type Extension, @@ -12,7 +12,7 @@ import type RedisClient from 'ioredis'; import { readVarString } from 'lib0/decoding.js'; import type { WebSocket } from 'ws'; import { CollabProxySocket } from './collab-proxy-socket'; -import { Injectable } from '@nestjs/common'; +import { Injectable, Logger } from '@nestjs/common'; import type { BaseWebSocket, Configuration, @@ -37,6 +37,7 @@ type SocketId = string; @Injectable() export class RedisSyncExtension implements Extension { + private readonly logger = new Logger('Collab' + RedisSyncExtension.name); priority = 1000; private readonly pub: RedisClient; private sub: RedisClient; @@ -274,6 +275,7 @@ export class RedisSyncExtension implements Extension { const proxyTo = await this.getOrClaimLockThrottled(documentName); if (proxyTo && proxyTo !== this.serverId) { + this.logger.debug(`Doc "${documentName}" owned by server ${proxyTo}, forwarding event "${eventName}"`); ++this.replyIdCounter; // bug in biome thinks this.replyIdCounter is not used if written on the line below const replyId = this.replyIdCounter; // another server owns the doc @@ -345,6 +347,7 @@ export class RedisSyncExtension implements Extension { const proxyTo = await this.getOrClaimLockThrottled(documentName); if (proxyTo && proxyTo !== this.serverId) { + this.logger.debug(`Doc "${documentName}" owned by server ${proxyTo}, proxying message`); // another server owns the doc const proxyMessage: RSAMessageProxy = { serializedHTTPRequest: serializedHTTPRequest,