{"record":{"id":"df30dc5793057231","repo":"ComposioHQ/composio","slug":"pusher-client-not-initialized","errorCode":null,"errorMessage":"Pusher client not initialized","messagePattern":"Pusher client not initialized","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/utils/pusher.ts","lineNumber":235,"sourceCode":"    }\n  }\n\n  /**\n   * Subscribes to a trigger channel for a client and handles chunked data.\n   * @param {string} clientId - The unique identifier for the client subscribing to the events.\n   * @param {(data: TriggerData) => void} fn - The callback function to execute when trigger data is received.\n   *\n   * @example\n   * ```ts\n   * composio.trigger.subscribe((data) => {\n   *   console.log(data);\n   * });\n   * ```\n   */\n  static triggerSubscribe(clientId: string, fn: (data: TriggerData) => void): void {\n    try {\n      if (!PusherUtils.pusherClient) {\n        throw new Error('Pusher client not initialized');\n      }\n\n      const channel = PusherUtils.pusherClient.subscribe(`private-${clientId}_triggers`);\n\n      // Add subscription error handling\n      channel.bind('pusher:subscription_error', (data: Record<string, unknown>) => {\n        const error = data.error ? String(data.error) : 'Unknown subscription error';\n        throw new PusherSubscriptionError(`Trigger subscription error`, {\n          cause: error,\n        });\n      });\n\n      // Wrap the callback to handle errors\n      const safeCallback = (data: TriggerData) => {\n        try {\n          fn(data);\n        } catch (error: unknown) {\n          const errorMessage = error instanceof Error ? error.message : String(error);","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/utils/pusher.ts#L217-L253","documentation":"triggerSubscribe requires the realtime Pusher client to already be initialized (via getPusherClient). Calling it before getPusherClient has completed throws this guard error because PusherUtils.pusherClient is undefined.","triggerScenarios":"Calling PusherUtils.triggerSubscribe(clientId, fn) (directly, or via a trigger API path that skips initialization) before awaiting getPusherClient(baseURL, apiKey) in the same process.","commonSituations":"Race where getPusherClient's promise isn't awaited; using the SDK in a fresh worker/process where only the subscribe path was invoked; code that caches a clientId across restarts and re-subscribes without re-initializing.","solutions":["Await getPusherClient(baseURL, apiKey) before calling triggerSubscribe","Check PusherUtils.pusherClient (or the public SDK accessor) is set before subscribing","Ensure initialization isn't swallowed by an earlier try/catch that ate the init error"],"exampleFix":"// before\nPusherUtils.triggerSubscribe(clientId, fn);\n\n// after\nawait PusherUtils.getPusherClient(baseURL, apiKey);\nPusherUtils.triggerSubscribe(clientId, fn);","handlingStrategy":"validation","validationCode":"await PusherUtils.getPusherClient(baseURL, apiKey); // must complete first\nif (!PusherUtils.pusherClient) throw new Error('init required');","typeGuard":null,"tryCatchPattern":"try {\n  PusherUtils.triggerSubscribe(clientId, fn);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Pusher client not initialized') {\n    await PusherUtils.getPusherClient(baseURL, apiKey);\n    PusherUtils.triggerSubscribe(clientId, fn);\n  }\n}","preventionTips":["Always await client initialization before subscribing","Centralize realtime setup in one bootstrap function","Never assume SDK static state survives process restarts"],"tags":["pusher","initialization-order","realtime","typescript"],"backgroundTag":"client-not-initialized","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}