Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-1338] Add channel and id properties to error message on subscription failure. #2678

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading