debug logging

This commit is contained in:
Philipinho
2026-01-25 14:01:32 +00:00
parent 353ec2559a
commit e755207c3b
2 changed files with 9 additions and 6 deletions
@@ -8,11 +8,11 @@ import type {
} from './redis-sync.types'; } from './redis-sync.types';
export class CollabProxySocket extends EventEmitter { export class CollabProxySocket extends EventEmitter {
private replyTo: string; private readonly replyTo: string;
private pongChannel: string; private readonly pongChannel: string;
private socketId: string; private readonly socketId: string;
private pub: RedisClient; private pub: RedisClient;
private pack: Pack; private readonly pack: Pack;
readyState = 1; readyState = 1;
constructor( constructor(
@@ -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 { IncomingMessage } from 'node:http';
import { import {
type Extension, type Extension,
@@ -12,7 +12,7 @@ import type RedisClient from 'ioredis';
import { readVarString } from 'lib0/decoding.js'; import { readVarString } from 'lib0/decoding.js';
import type { WebSocket } from 'ws'; import type { WebSocket } from 'ws';
import { CollabProxySocket } from './collab-proxy-socket'; import { CollabProxySocket } from './collab-proxy-socket';
import { Injectable } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import type { import type {
BaseWebSocket, BaseWebSocket,
Configuration, Configuration,
@@ -37,6 +37,7 @@ type SocketId = string;
@Injectable() @Injectable()
export class RedisSyncExtension<TCE extends CustomEvents> implements Extension { export class RedisSyncExtension<TCE extends CustomEvents> implements Extension {
private readonly logger = new Logger('Collab' + RedisSyncExtension.name);
priority = 1000; priority = 1000;
private readonly pub: RedisClient; private readonly pub: RedisClient;
private sub: RedisClient; private sub: RedisClient;
@@ -274,6 +275,7 @@ export class RedisSyncExtension<TCE extends CustomEvents> implements Extension {
const proxyTo = await this.getOrClaimLockThrottled(documentName); const proxyTo = await this.getOrClaimLockThrottled(documentName);
if (proxyTo && proxyTo !== this.serverId) { 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 ++this.replyIdCounter; // bug in biome thinks this.replyIdCounter is not used if written on the line below
const replyId = this.replyIdCounter; const replyId = this.replyIdCounter;
// another server owns the doc // another server owns the doc
@@ -345,6 +347,7 @@ export class RedisSyncExtension<TCE extends CustomEvents> implements Extension {
const proxyTo = await this.getOrClaimLockThrottled(documentName); const proxyTo = await this.getOrClaimLockThrottled(documentName);
if (proxyTo && proxyTo !== this.serverId) { if (proxyTo && proxyTo !== this.serverId) {
this.logger.debug(`Doc "${documentName}" owned by server ${proxyTo}, proxying message`);
// another server owns the doc // another server owns the doc
const proxyMessage: RSAMessageProxy = { const proxyMessage: RSAMessageProxy = {
serializedHTTPRequest: serializedHTTPRequest, serializedHTTPRequest: serializedHTTPRequest,