From 4cdfae6a05e7d94e756b697ce436d0f65831b244 Mon Sep 17 00:00:00 2001 From: vincentwschau <99756290+vincentwschau@users.noreply.github.com> Date: Wed, 8 Jan 2025 17:19:46 -0500 Subject: [PATCH] [CT-1338] Add channel and id properties to error message on subscription failure. (#2678) --- indexer/services/socks/__tests__/lib/subscriptions.test.ts | 4 ++++ indexer/services/socks/src/helpers/message.ts | 4 ++++ indexer/services/socks/src/lib/subscription.ts | 2 ++ indexer/services/socks/src/types.ts | 2 ++ 4 files changed, 12 insertions(+) diff --git a/indexer/services/socks/__tests__/lib/subscriptions.test.ts b/indexer/services/socks/__tests__/lib/subscriptions.test.ts index 6f38ab1fe6..f23d1bb254 100644 --- a/indexer/services/socks/__tests__/lib/subscriptions.test.ts +++ b/indexer/services/socks/__tests__/lib/subscriptions.test.ts @@ -244,6 +244,8 @@ describe('Subscriptions', () => { message: expect.stringContaining( `Internal error, could not fetch data for subscription: ${Channel.V4_ACCOUNTS}`, ), + channel: Channel.V4_ACCOUNTS, + id: mockSubaccountId, })); expect(subscriptions.subscriptions[Channel.V4_ACCOUNTS]).toBeUndefined(); expect(subscriptions.subscriptionLists[connectionId]).toBeUndefined(); @@ -278,6 +280,8 @@ describe('Subscriptions', () => { connection_id: connectionId, type: 'error', message: expectedError.message, + channel: Channel.V4_ACCOUNTS, + id: mockSubaccountId, })); expect(subscriptions.subscriptions[Channel.V4_ACCOUNTS]).toBeUndefined(); expect(subscriptions.subscriptionLists[connectionId]).toBeUndefined(); diff --git a/indexer/services/socks/src/helpers/message.ts b/indexer/services/socks/src/helpers/message.ts index 2bec8327d8..413aab9f6e 100644 --- a/indexer/services/socks/src/helpers/message.ts +++ b/indexer/services/socks/src/helpers/message.ts @@ -13,12 +13,16 @@ export function createErrorMessage( message: string, connectionId: string, messageId: number, + channel?: string, + id?: string, ): ErrorMessage { return { type: OutgoingMessageType.ERROR, message, connection_id: connectionId, message_id: messageId, + channel, + id, }; } diff --git a/indexer/services/socks/src/lib/subscription.ts b/indexer/services/socks/src/lib/subscription.ts index 48e3f7f8ec..3ae0513d25 100644 --- a/indexer/services/socks/src/lib/subscription.ts +++ b/indexer/services/socks/src/lib/subscription.ts @@ -172,6 +172,8 @@ export class Subscriptions { errorMsg, connectionId, messageId, + channel, + id, ), ); diff --git a/indexer/services/socks/src/types.ts b/indexer/services/socks/src/types.ts index 9964b6c753..ded1b4cf9a 100644 --- a/indexer/services/socks/src/types.ts +++ b/indexer/services/socks/src/types.ts @@ -67,6 +67,8 @@ export interface OutgoingMessage { export interface ErrorMessage extends OutgoingMessage { message: string, + channel?: string, + id?: string, } export interface SubscribedMessage extends OutgoingMessage {