From 6f0795ff92fc18e56bb27ae689f7005503ea7d6c Mon Sep 17 00:00:00 2001 From: Ryo Igarashi Date: Mon, 21 Oct 2024 23:57:08 +0900 Subject: [PATCH] chore: Parse WebSocket events synchronously --- src/adapters/ws/web-socket-subscription.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/adapters/ws/web-socket-subscription.ts b/src/adapters/ws/web-socket-subscription.ts index e421624f..92de5c5e 100644 --- a/src/adapters/ws/web-socket-subscription.ts +++ b/src/adapters/ws/web-socket-subscription.ts @@ -40,7 +40,7 @@ export class WebSocketSubscription implements mastodon.streaming.Subscription { const messages = toAsyncIterable(this.connection); for await (const message of messages) { - const event = await this.parseMessage(message.data as string); + const event = this.parseMessage(message.data as string); if (!this.test(event)) { continue; @@ -95,9 +95,7 @@ export class WebSocketSubscription implements mastodon.streaming.Subscription { return stream.every((s) => event.stream.includes(s)); } - private async parseMessage( - rawEvent: string, - ): Promise { + private parseMessage(rawEvent: string): mastodon.streaming.Event { const data = this.serializer.deserialize( "json", rawEvent,