{"version":3,"file":"timeout.cjs","names":["ZamaError","ZamaErrorCode"],"sources":["../../src/errors/timeout.ts"],"sourcesContent":["import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/**\n * A worker operation (encrypt / decrypt / EIP-712 / key fetch) did not complete\n * within its configured timeout — typically a stuck relayer or WASM call. On the\n * Node pool the SDK **recycles the affected worker** (terminating the hung\n * thread) so it self-heals; the operation itself is **retryable**.\n *\n * Configure the bound (seconds) via `node({ operationTimeout })`. Distinct from a\n * decryption/entitlement failure — a timeout is an infrastructure/latency\n * condition, so it no longer collapses into {@link DecryptionFailedError}.\n *\n * @example\n * ```ts\n * try {\n *   await sdk.decryption.decryptValues([{ encryptedValue, contractAddress }]);\n * } catch (e) {\n *   if (e instanceof WorkerTimeoutError) {\n *     // retry (the worker was recycled); consider raising operationTimeout\n *   }\n * }\n * ```\n */\nexport class WorkerTimeoutError extends ZamaError {\n  /**\n   * The worker operation that timed out. This is the internal worker op code\n   * (e.g. `USER_DECRYPT`, `ENCRYPT`), not the public SDK method name.\n   */\n  readonly operation: string;\n  /** The configured timeout that was exceeded, in **seconds** (the SDK's duration unit). */\n  readonly timeout: number;\n  /** Wall-clock time the operation ran before being abandoned, in **seconds** (may be fractional). */\n  readonly elapsed: number;\n  /** Label of the worker that stalled, when known (e.g. `node-worker-2`). */\n  readonly worker: string | undefined;\n\n  constructor(\n    args: { operation: string; timeout: number; elapsed: number; worker?: string },\n    options?: ErrorOptions,\n  ) {\n    super(\n      ZamaErrorCode.OperationTimeout,\n      `Worker operation ${args.operation} timed out after ${args.timeout}s` +\n        (args.worker ? ` (worker ${args.worker})` : \"\"),\n      options,\n    );\n    this.name = \"WorkerTimeoutError\";\n    this.operation = args.operation;\n    this.timeout = args.timeout;\n    this.elapsed = args.elapsed;\n    this.worker = args.worker;\n  }\n}\n\n/**\n * An in-flight worker operation was aborted as **collateral** when its worker was\n * recycled — the worker was torn down to recover from *another* operation's\n * timeout (Node pool self-healing), not because this operation itself timed out.\n *\n * The operation never reached a verdict, so it is **retryable**: the next call\n * lazily re-inits a fresh worker. It is intentionally distinct from\n * {@link WorkerTimeoutError} (this op did not exceed its own bound) and from\n * {@link DecryptionFailedError} (nothing actually failed to decrypt) — so a\n * consumer can retry it instead of surfacing a terminal failure.\n *\n * @example\n * ```ts\n * matchZamaError(error, {\n *   WORKER_RECYCLED: () => retry(), // transient: the worker was replaced\n * });\n * ```\n */\nexport class WorkerRecycledError extends ZamaError {\n  /**\n   * The worker operation that was aborted. This is the internal worker op code\n   * (e.g. `USER_DECRYPT`, `ENCRYPT`), not the public SDK method name.\n   */\n  readonly operation: string;\n  /** Label of the recycled worker, when known (e.g. `node-worker-2`). */\n  readonly worker: string | undefined;\n\n  constructor(args: { operation: string; worker?: string }, options?: ErrorOptions) {\n    super(\n      ZamaErrorCode.WorkerRecycled,\n      `Worker operation ${args.operation} was aborted because its worker was recycled after a timeout` +\n        (args.worker ? ` (worker ${args.worker})` : \"\"),\n      options,\n    );\n    this.name = \"WorkerRecycledError\";\n    this.operation = args.operation;\n    this.worker = args.worker;\n  }\n}\n"],"mappings":"iCAuBA,IAAa,EAAb,cAAwCA,EAAAA,CAAU,CAKhD,UAEA,QAEA,QAEA,OAEA,YACE,EACA,EACA,CACA,MACEC,EAAAA,EAAc,iBACd,oBAAoB,EAAK,UAAU,mBAAmB,EAAK,QAAQ,IAChE,EAAK,OAAS,YAAY,EAAK,OAAO,GAAK,IAC9C,CACF,EACA,KAAK,KAAO,qBACZ,KAAK,UAAY,EAAK,UACtB,KAAK,QAAU,EAAK,QACpB,KAAK,QAAU,EAAK,QACpB,KAAK,OAAS,EAAK,MACrB,CACF,EAoBa,EAAb,cAAyCD,EAAAA,CAAU,CAKjD,UAEA,OAEA,YAAY,EAA8C,EAAwB,CAChF,MACEC,EAAAA,EAAc,eACd,oBAAoB,EAAK,UAAU,+DAChC,EAAK,OAAS,YAAY,EAAK,OAAO,GAAK,IAC9C,CACF,EACA,KAAK,KAAO,sBACZ,KAAK,UAAY,EAAK,UACtB,KAAK,OAAS,EAAK,MACrB,CACF"}