{"record":{"id":"a06989a7831507b2","repo":"ComposioHQ/composio","slug":"failed-to-unsubscribe-from-triggers-errormessag","errorCode":null,"errorMessage":"Failed to unsubscribe from triggers: ${errorMessage}","messagePattern":"Failed to unsubscribe from triggers: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"ts/packages/core/src/utils/pusher.ts","lineNumber":283,"sourceCode":"      logger.info(`Subscribed to triggers. You should start receiving events now.`);\n    } catch (error: unknown) {\n      const errorMessage = error instanceof Error ? error.message : String(error);\n      logger.error('Failed to subscribe to triggers:', error);\n      throw new Error(`Failed to subscribe to triggers: ${errorMessage}`);\n    }\n  }\n\n  static triggerUnsubscribe(clientId: string): void {\n    try {\n      if (!PusherUtils.pusherClient) {\n        throw new Error('Pusher client not initialized');\n      }\n      PusherUtils.pusherClient.unsubscribe(`private-${clientId}_triggers`);\n      logger.info('Successfully unsubscribed from triggers');\n    } catch (error: unknown) {\n      const errorMessage = error instanceof Error ? error.message : String(error);\n      logger.error('Failed to unsubscribe from triggers:', error);\n      throw new Error(`Failed to unsubscribe from triggers: ${errorMessage}`);\n    }\n  }\n}\n","sourceCodeStart":265,"sourceCodeEnd":287,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/utils/pusher.ts#L265-L287","documentation":"Catch-all wrapper for failures in triggerUnsubscribe; the underlying message is appended. Usually wraps error 407 (client not initialized) or a pusher-js unsubscribe exception on a dead connection.","triggerScenarios":"Calling triggerUnsubscribe when the client is missing (407) or when the underlying websocket has already disconnected and unsubscribe throws.","commonSituations":"Cleanup paths racing with disconnects; teardown during process shutdown after the connection dropped.","solutions":["Check the appended underlying message","Skip unsubscribe when the client is uninitialized or the connection is already closed (idempotent teardown)","Wrap teardown in a best-effort try/catch that logs rather than throws during shutdown"],"exampleFix":"// before\nPusherUtils.triggerUnsubscribe(clientId);\n\n// after\ntry {\n  PusherUtils.triggerUnsubscribe(clientId);\n} catch {\n  // best-effort teardown; connection already gone\n}","handlingStrategy":"fallback","validationCode":"if (PusherUtils.pusherClient) {\n  PusherUtils.triggerUnsubscribe(clientId);\n}","typeGuard":null,"tryCatchPattern":"try {\n  PusherUtils.triggerUnsubscribe(clientId);\n} catch {\n  // already disconnected; safe to ignore during shutdown\n}","preventionTips":["Never let unsubscribe failures break shutdown paths","Check the appended underlying message when it does matter","Pair subscribe/unsubscribe in the same lifecycle scope"],"tags":["pusher","cleanup","realtime","wrapper-error"],"backgroundTag":"event-unsubscribe-failed","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}