On this page

Errors & Recovery

Handle SDK errors and check whether the original operation reached the chain.

Read the error code#

The CommonJS SDK throws an Error with code and message fields. Branch on code and show the user an action they can take. Keep request envelopes and private account data out of diagnostic output.

These errors catch changed contracts, budgets and request content, as well as unresolved broadcasts. Resolve the reason before attempting to accept the original request again.

Common error codes#

CodeReasonNext step
PIN_MISMATCHThe deployment or authority changedCheck configuration against the intended chain and contracts
STORE_MISMATCHSaved policy or observed state no longer matchesReconcile the original ledger; keep its records
CAPACITY_EXCEEDEDFunding or its configured limit is too smallFund within the agreed terms before retrying
BUDGET_EXCEEDEDPrepared purchases exceed the manager budgetApprove a new policy or session separately
REQUEST_CONFLICTA prepared ID has different content or priceUse its original request or assign a new job ID
REQUEST_MISMATCHContent or price differs from the server calculationCorrect the request or server billing context
REQUEST_EXPIREDThe signed deadline passedRenew the same request's signature if permitted
LIFECYCLE_UNCERTAINA broadcast outcome is unresolvedRecover and check chain state
MANAGER_EXPIREDThe application policy expiredStop new requests and settle before claim rights end
SESSION_NOT_OPENThe session is unfunded or closingCheck its funding and close state

Recover after a timeout#

A validation failure and a broadcast timeout need different handling. After submission, the transaction may succeed even if its response is lost. Save the intent and hash, then recover chain state before another mutation.

javascript
try {
  await merchant.settle();
} catch (error) {
  if (error.code === "LIFECYCLE_UNCERTAIN") {
    await merchant.recover();
    // Review the recovered intent and state before an explicit retry.
  } else {
    throw error;
  }
}

Check state before retrying#

Use session, hold and transaction state to choose the retry, rather than matching an error message. Repeating a settled target can be idempotent. Changing content under the same request ID is a conflict.

Stop authorization when RPC reads fail the freshness check, and wait for the RPC and clock to recover. Investigate reorganized or backward state instead of removing the stored observation floor.