Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 13:30 UTC
fix(core): contain async Pusher subscription errors
CoralGarden52 committed
Sep 11, 2026 at 15:29 UTC
efc2e5276df623d4b3d097b31e416b48083f25c3
3 files changed
+87
-6
.changeset/quiet-pumas-recover.md
new
+6
@@ -0,0 +1,6 @@
1
+---
2
+'@composio/core': patch
3
+'@composio/slim': patch
4
+---
5
+
6
+Keep TypeScript realtime subscription errors inside the SDK logging boundary so an asynchronous Pusher subscription failure cannot escape as an uncaught exception.
ts/packages/core/src/services/pusher/Pusher.ts
+1
-6
@@ -172,12 +172,7 @@ export class PusherService {
172
// add subscription error handling
173
channel.bind('pusher:subscription_error', (data: Record<string, unknown>) => {
174
const error = data.error ? String(data.error) : 'Unknown subscription error';
175
- throw new ComposioFailedToSubscribeToPusherChannelError(
176
- `Trigger subscription error: ${error}`,
177
- {
178
- cause: error,
179
- }
180
- );
175
+ logger.error(`Trigger subscription error: ${error}`);
176
});
177
178
// wrap the callback to handle errors
ts/packages/core/test/services/pusher.test.ts
new
+80
@@ -0,0 +1,80 @@
1
+import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+import { PusherService } from '../../src/services/pusher/Pusher';
3
+
4
+type EventHandler = (data: Record<string, unknown>) => void;
5
+
6
+const { bindings, mockChannel, mockPusherClient, mockGetCredentials, mockLoggerError } = vi.hoisted(
7
+ () => {
8
+ const eventBindings = new Map<string, EventHandler>();
9
+ const channel = {
10
+ bind: vi.fn((event: string, callback: EventHandler) => {
11
+ eventBindings.set(event, callback);
12
+ }),
13
+ emit: (event: string, data: Record<string, unknown>) => {
14
+ eventBindings.get(event)?.(data);
15
+ },
16
+ };
17
+
18
+ return {
19
+ bindings: eventBindings,
20
+ mockChannel: channel,
21
+ mockPusherClient: {
22
+ subscribe: vi.fn().mockResolvedValue(channel),
23
+ unsubscribe: vi.fn().mockResolvedValue(undefined),
24
+ },
25
+ mockGetCredentials: vi.fn().mockResolvedValue({
26
+ projectId: 'project-id',
27
+ pusherKey: 'pusher-key',
28
+ pusherCluster: 'mt1',
29
+ }),
30
+ mockLoggerError: vi.fn(),
31
+ };
32
+ }
33
+);
34
+
35
+vi.mock('pusher-js', () => ({
36
+ default: class FakePusher {
37
+ subscribe = mockPusherClient.subscribe;
38
+ unsubscribe = mockPusherClient.unsubscribe;
39
+ },
40
+}));
41
+
42
+vi.mock('../../src/services/internal/InternalService', () => ({
43
+ InternalService: class FakeInternalService {
44
+ getSDKRealtimeCredentials = mockGetCredentials;
45
+ },
46
+}));
47
+
48
+vi.mock('../../src/utils/logger', () => ({
49
+ default: {
50
+ debug: vi.fn(),
51
+ error: mockLoggerError,
52
+ info: vi.fn(),
53
+ warn: vi.fn(),
54
+ },
55
+}));
56
+
57
+describe('PusherService subscription errors', () => {
58
+ beforeEach(() => {
59
+ bindings.clear();
60
+ mockGetCredentials.mockClear();
61
+ mockPusherClient.subscribe.mockClear();
62
+ mockLoggerError.mockClear();
63
+ });
64
+
65
+ it('contains subscription errors emitted after subscribe resolves', async () => {
66
+ const service = new PusherService({
67
+ baseURL: 'https://backend.composio.dev',
68
+ apiKey: 'api-key',
69
+ } as never);
70
+
71
+ await service.subscribe(vi.fn());
72
+
73
+ expect(() => {
74
+ mockChannel.emit('pusher:subscription_error', { error: 401 });
75
+ }).not.toThrow();
76
+ expect(mockLoggerError).toHaveBeenCalledWith(
77
+ expect.stringContaining('Trigger subscription error: 401')
78
+ );
79
+ });
80
+});