{"record":{"id":"924f95eff0b3b200","repo":"ComposioHQ/composio","slug":"request-was-cancelled-by-the-caller","errorCode":null,"errorMessage":"Request was cancelled by the caller","messagePattern":"Request was cancelled by the caller","errorType":"exception","errorClass":"ComposioRequestCancelledError","httpStatus":null,"severity":"info","filePath":"ts/packages/core/src/utils/cancellation.ts","lineNumber":16,"sourceCode":"import { ComposioRequestCancelledError, isRequestAbortError } from '../errors/SDKErrors';\n\n/** @internal */\nexport async function withCancellation<T>(\n  call: () => Promise<T>,\n  signal?: AbortSignal\n): Promise<T> {\n  try {\n    return await call();\n  } catch (error) {\n    if (signal?.aborted && isRequestAbortError(error)) {\n      const underlyingMessage = error instanceof Error ? error.message : '';\n      const message = underlyingMessage\n        ? `Request was cancelled by the caller: ${underlyingMessage}`\n        : 'Request was cancelled by the caller';\n      throw new ComposioRequestCancelledError(message, {\n        cause: error instanceof Error ? error : undefined,\n      });\n    }\n    throw error;\n  }\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/utils/cancellation.ts#L1-L23","documentation":"Thrown by withCancellation when the caller-provided AbortSignal was aborted and the underlying fetch failed with an abort error. It wraps the abort into ComposioRequestCancelledError so callers can distinguish intentional cancellation from real network failures.","triggerScenarios":"Passing an AbortSignal to a request method (response, result, update, delete, updateStatus, enable) and calling signal.abort() (or aborting a controller on timeout) while the HTTP request is in flight.","commonSituations":"Timeouts implemented with AbortController.timeout(), UI cancel buttons, racing requests, or shared controllers aborted too early (e.g. React StrictMode double-effect aborting on mount).","solutions":["Treat this error as expected: check e.name === 'ComposioRequestCancelledError' (or instanceof) and skip retry logic.","If it fires unexpectedly, ensure you are not aborting the controller before the awaited call completes (double-abort or premature cleanup).","For timeouts, consider retry with backoff instead of propagating cancellation."],"exampleFix":"// before\nconst res = await composio.requests.response(id, { signal });\n// after\ntry {\n  const res = await composio.requests.response(id, { signal });\n} catch (e) {\n  if (e instanceof ComposioRequestCancelledError) return; // intentional cancel\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["abort","cancellation","network","typescript"],"backgroundTag":"request-aborted","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}