Skip to content

Commit

Permalink
[CT-1338] Add channel and id properties to error message on subscript…
Browse files Browse the repository at this point in the history
…ion failure. (#2678)

(cherry picked from commit 4cdfae6)
  • Loading branch information
vincentwschau authored and mergify[bot] committed Jan 8, 2025
1 parent 58c0475 commit d0492ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions indexer/services/socks/__tests__/lib/subscriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions indexer/services/socks/src/helpers/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down
2 changes: 2 additions & 0 deletions indexer/services/socks/src/lib/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ export class Subscriptions {
errorMsg,
connectionId,
messageId,
channel,
id,
),
);

Expand Down
2 changes: 2 additions & 0 deletions indexer/services/socks/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export interface OutgoingMessage {

export interface ErrorMessage extends OutgoingMessage {
message: string,
channel?: string,
id?: string,
}

export interface SubscribedMessage extends OutgoingMessage {
Expand Down

0 comments on commit d0492ee

Please sign in to comment.