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 { WsSocketWrapper } from './extensions/redis-sync/ws-socket-wrapper';
import RedisClient from 'ioredis'; import RedisClient from 'ioredis';
import { pack, unpack } from 'msgpackr'; import { pack, unpack } from 'msgpackr';
import { CollabWsAdapter } from './adapter/collab-ws.adapter';
@Injectable() @Injectable()
export class CollaborationGateway { export class CollaborationGateway {
@@ -122,8 +123,7 @@ export class CollaborationGateway {
return this.hocuspocus.getDocumentsCount(); return this.hocuspocus.getDocumentsCount();
} }
async destroy(): Promise<void> { async destroy(collabWsAdapter: CollabWsAdapter): Promise<void> {
await new Promise((r) => setTimeout(r, 10000));
// eslint-disable-next-line no-async-promise-executor // eslint-disable-next-line no-async-promise-executor
await new Promise(async (resolve) => { await new Promise(async (resolve) => {
try { try {
@@ -134,6 +134,8 @@ export class CollaborationGateway {
}, },
}); });
collabWsAdapter?.close();
if (this.hocuspocus.getDocumentsCount() === 0) resolve(''); if (this.hocuspocus.getDocumentsCount() === 0) resolve('');
this.hocuspocus.closeConnections(); this.hocuspocus.closeConnections();
} catch (error) { } catch (error) {
@@ -51,8 +51,7 @@ export class CollaborationModule implements OnModuleInit, OnModuleDestroy {
} }
async onModuleDestroy(): Promise<void> { async onModuleDestroy(): Promise<void> {
this.collabWsAdapter?.close(); await this.collaborationGateway?.destroy(this.collabWsAdapter);
await this.collaborationGateway?.destroy();
this.collabWsAdapter?.destroy(); this.collabWsAdapter?.destroy();
} }
} }