From aa47a3be67fb505c8d92334abd6d0552b0f227f0 Mon Sep 17 00:00:00 2001 From: Ryo Igarashi Date: Sun, 20 Oct 2024 23:07:02 +0900 Subject: [PATCH] fix: Fix WebSocket to send subscribe event before unsubscribe --- src/adapters/ws/web-socket-subscription.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/adapters/ws/web-socket-subscription.ts b/src/adapters/ws/web-socket-subscription.ts index e421624f..448ca24c 100644 --- a/src/adapters/ws/web-socket-subscription.ts +++ b/src/adapters/ws/web-socket-subscription.ts @@ -23,9 +23,9 @@ export class WebSocketSubscription implements mastodon.streaming.Subscription { ) {} async *values(): AsyncIterableIterator { - try { - this.logger?.log("info", "Subscribing to stream", this.stream); + this.logger?.log("info", "Subscribing to stream", this.stream); + try { for await (this.connection of this.connector) { const data = this.serializer.serialize("json", { type: "subscribe", @@ -46,7 +46,10 @@ export class WebSocketSubscription implements mastodon.streaming.Subscription { continue; } - this.logger?.log("debug", "↓ WEBSOCKET", event); + this.logger?.log( + "info", + `↓ WEBSOCKET ${JSON.stringify(event).slice(0, 100)}`, + ); yield event; } } @@ -69,6 +72,10 @@ export class WebSocketSubscription implements mastodon.streaming.Subscription { ...this.params, }); + this.logger?.log( + "info", + `↑ WEBSOCKET ${JSON.stringify(data).slice(0, 100)}`, + ); this.connection.send(data); }