pass wsAdapter to gateway

This commit is contained in:
Philipinho
2026-01-25 21:47:04 +00:00
parent 793d61a13e
commit 3157131bf2
2 changed files with 5 additions and 4 deletions
@@ -18,6 +18,7 @@ import {
import { WsSocketWrapper } from './extensions/redis-sync/ws-socket-wrapper';
import RedisClient from 'ioredis';
import { pack, unpack } from 'msgpackr';
import { CollabWsAdapter } from './adapter/collab-ws.adapter';
@Injectable()
export class CollaborationGateway {
@@ -122,8 +123,7 @@ export class CollaborationGateway {
return this.hocuspocus.getDocumentsCount();
}
async destroy(): Promise<void> {
await new Promise((r) => setTimeout(r, 10000));
async destroy(collabWsAdapter: CollabWsAdapter): Promise<void> {
// eslint-disable-next-line no-async-promise-executor
await new Promise(async (resolve) => {
try {
@@ -134,6 +134,8 @@ export class CollaborationGateway {
},
});
collabWsAdapter?.close();
if (this.hocuspocus.getDocumentsCount() === 0) resolve('');
this.hocuspocus.closeConnections();
} catch (error) {
@@ -51,8 +51,7 @@ export class CollaborationModule implements OnModuleInit, OnModuleDestroy {
}
async onModuleDestroy(): Promise<void> {
this.collabWsAdapter?.close();
await this.collaborationGateway?.destroy();
await this.collaborationGateway?.destroy(this.collabWsAdapter);
this.collabWsAdapter?.destroy();
}
}