unique collab serverId generation

This commit is contained in:
Philipinho
2026-01-26 13:55:20 +00:00
parent 75673ad964
commit 6aff7b84f2
3 changed files with 6 additions and 4 deletions
@@ -18,6 +18,8 @@ import {
import { WsSocketWrapper } from './extensions/redis-sync/ws-socket-wrapper';
import RedisClient from 'ioredis';
import { pack, unpack } from 'msgpackr';
import { nanoid } from 'nanoid';
import * as os from 'node:os';
import { CollabWsAdapter } from './adapter/collab-ws.adapter';
import {
CollaborationHandler,
@@ -65,7 +67,7 @@ export class CollaborationGateway {
family: this.redisConfig.family,
retryStrategy: createRetryStrategy(),
}),
serverId: `collab-${process.pid}`,
serverId: `collab-${os?.hostname()}-${nanoid(10)}`,
prefix: 'collab',
pack,
unpack,
@@ -1,4 +1,4 @@
// Adapted from https://github.com/ueberdosis/hocuspocus/pull/1008 - MIT
// Source https://github.com/ueberdosis/hocuspocus/pull/1008 - MIT
import { IncomingMessage } from 'node:http';
import {
Extension,
@@ -12,7 +12,7 @@ import RedisClient from 'ioredis';
import { readVarString } from 'lib0/decoding.js';
import { WebSocket } from 'ws';
import { CollabProxySocket } from './collab-proxy-socket';
import { Injectable, Logger } from '@nestjs/common';
import { Logger } from '@nestjs/common';
import {
BaseWebSocket,
Configuration,