From ea5c893f2b31b4a9c8f0fe539b05d00b05aa1a13 Mon Sep 17 00:00:00 2001 From: Kevin Kipp Date: Fri, 4 Oct 2024 14:56:34 -0500 Subject: [PATCH] Add logging for onClose Even though we don't do anything here, I want to capture information here! --- app/durableObjects/ChatRoom.server.ts | 17 +++++++++++++++++ app/utils/logging.ts | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/app/durableObjects/ChatRoom.server.ts b/app/durableObjects/ChatRoom.server.ts index 9fa42472..521f9d3e 100644 --- a/app/durableObjects/ChatRoom.server.ts +++ b/app/durableObjects/ChatRoom.server.ts @@ -194,6 +194,23 @@ export class ChatRoom extends Server { } } + async onClose( + connection: Connection, + code: number, + reason: string, + wasClean: boolean + ) { + const meetingId = await this.getMeetingId() + log({ + eventName: 'onClose', + meetingId, + connectionId: connection.id, + code, + reason, + wasClean, + }) + } + async onMessage( connection: Connection, message: WSMessage diff --git a/app/utils/logging.ts b/app/utils/logging.ts index cbddf06a..a4ae461d 100644 --- a/app/utils/logging.ts +++ b/app/utils/logging.ts @@ -13,6 +13,14 @@ export type LogEvent = foundInStorage: boolean connectionId: string } + | { + eventName: 'onClose' + meetingId?: string + connectionId: string + code: number + reason: string + wasClean: boolean + } | { eventName: 'userLeft' meetingId?: string