From 7396910704afc5b149fa0a89cf89620323cf9aeb Mon Sep 17 00:00:00 2001 From: davwas Date: Thu, 16 Nov 2023 16:33:10 +0100 Subject: [PATCH] add some console logs --- .../modules/tldraw/domain/ws-shared-doc.do.ts | 27 +++++++++++-------- .../tldraw/service/tldraw.ws.service.ts | 4 +-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/apps/server/src/modules/tldraw/domain/ws-shared-doc.do.ts b/apps/server/src/modules/tldraw/domain/ws-shared-doc.do.ts index b675cac5f2c..42f02ebbeb5 100644 --- a/apps/server/src/modules/tldraw/domain/ws-shared-doc.do.ts +++ b/apps/server/src/modules/tldraw/domain/ws-shared-doc.do.ts @@ -33,18 +33,23 @@ export class WsSharedDocDo extends Doc { await this.tldrawService.updateHandler(update, origin, doc); }); - void this.tldrawService.sub.subscribe(this.name, this.awarenessChannel).then(() => { - this.tldrawService.sub.on('messageBuffer', (channel, update: Uint8Array) => { - const channelId = channel.toString(); + this.tldrawService.sub + .subscribe(this.name, this.awarenessChannel) + .then(() => { + console.log('SUBSCRIBED TO CHANNELS'); + this.tldrawService.sub.on('messageBuffer', (channel, update: Uint8Array) => { + const channelId = channel.toString(); + console.log('LISTENED TO MESSAGEBUFFER ON: ', channelId); - if (channelId === this.name) { - applyUpdate(this, update, this.tldrawService.sub); - } else if (channelId === this.awarenessChannel) { - applyAwarenessUpdate(this.awareness, update, this.tldrawService.sub); - } - }); - return null; - }); + if (channelId === this.name) { + applyUpdate(this, update, this.tldrawService.sub); + } else if (channelId === this.awarenessChannel) { + applyAwarenessUpdate(this.awareness, update, this.tldrawService.sub); + } + }); + return null; + }) + .catch((err) => console.log(err)); } /** diff --git a/apps/server/src/modules/tldraw/service/tldraw.ws.service.ts b/apps/server/src/modules/tldraw/service/tldraw.ws.service.ts index a97cafd30a7..f69e22a157b 100644 --- a/apps/server/src/modules/tldraw/service/tldraw.ws.service.ts +++ b/apps/server/src/modules/tldraw/service/tldraw.ws.service.ts @@ -53,7 +53,7 @@ export class TldrawWsService { doc.destroy(); return null; }) - .catch(() => {}); + .catch((err) => console.log(err)); this.docs.delete(doc.name); } } @@ -113,7 +113,7 @@ export class TldrawWsService { return map.setIfUndefined(this.docs, docName, () => { const doc = new WsSharedDocDo(docName, this, gc); if (this.persistence !== null) { - this.persistence.bindState(docName, doc).catch(() => {}); + this.persistence.bindState(docName, doc).catch((err) => console.log(err)); } this.docs.set(docName, doc); return doc;