Skip to content

Commit

Permalink
Merge pull request #1227 from neet/fix-unsubscribe-timing
Browse files Browse the repository at this point in the history
chore: Parse WebSocket events synchronously
  • Loading branch information
neet authored Oct 21, 2024
2 parents 6219c18 + 6f0795f commit c84e9d8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/adapters/ws/web-socket-subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<mastodon.streaming.Event> {
private parseMessage(rawEvent: string): mastodon.streaming.Event {
const data = this.serializer.deserialize<mastodon.streaming.RawEvent>(
"json",
rawEvent,
Expand Down

0 comments on commit c84e9d8

Please sign in to comment.