hyperledger/fabric · error

failed to execute transaction %s

Error message

failed to execute transaction %s

What it means

processChaincodeExecutionResult wraps any error returned from cs.Invoke (executing the chaincode transaction) with 'failed to execute transaction <txid>'. It is the top-level error users of the peer SDK/CLI see when a chaincode invocation fails anywhere between the peer dispatching the transaction and the chaincode returning a result. The wrapped cause contains the true failure (launch failure, auth error, chaincode error, timeout).

Source

Thrown at core/chaincode/chaincode_support.go:175

	h, err := cs.Launch(ccid)
	if err != nil {
		return nil, nil, err
	}

	resp, err := cs.execute(pb.ChaincodeMessage_INIT, txParams, ccName, input, h)
	return processChaincodeExecutionResult(txParams.TxID, ccName, resp, err)
}

// Execute invokes chaincode and returns the original response.
func (cs *ChaincodeSupport) Execute(txParams *ccprovider.TransactionParams, chaincodeName string, input *pb.ChaincodeInput) (*pb.Response, *pb.ChaincodeEvent, error) {
	resp, err := cs.Invoke(txParams, chaincodeName, input)
	return processChaincodeExecutionResult(txParams.TxID, chaincodeName, resp, err)
}

func processChaincodeExecutionResult(txid, ccName string, resp *pb.ChaincodeMessage, err error) (*pb.Response, *pb.ChaincodeEvent, error) {
	if err != nil {
		return nil, nil, errors.Wrapf(err, "failed to execute transaction %s", txid)
	}
	if resp == nil {
		return nil, nil, errors.Errorf("nil response from transaction %s", txid)
	}

	if resp.ChaincodeEvent != nil {
		resp.ChaincodeEvent.ChaincodeId = ccName
		resp.ChaincodeEvent.TxId = txid
	}

	switch resp.Type {
	case pb.ChaincodeMessage_COMPLETED:
		res := &pb.Response{}
		err := proto.Unmarshal(resp.Payload, res)
		if err != nil {
			return nil, nil, errors.Wrapf(err, "failed to unmarshal response for transaction %s", txid)
		}
		return res, resp.ChaincodeEvent, nil

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Unwrap the cause in the error chain (it names the underlying problem, e.g. launch failure or chaincode error) and address that specific issue first.
  2. If the cause is a chaincode error, inspect the chaincode logic/logs and fix the failing function or arguments in the invocation.
  3. If the cause is a launch/connect failure, ensure the chaincode container is running and can reach the peer (see errors 391/392).
  4. Increase chaincode.startuptimeout / request timeout if cold starts time out on first invocation.

Example fix

// before: first invocation after deploy times out due to cold start
const result = await contract.submitTransaction('createAsset', 'a1');
// after: perform a warm-up invoke or raise the peer's chaincode.startuptimeout
await contract.submitTransaction('initLedger'); // warm-up
const result = await contract.submitTransaction('createAsset', 'a1');
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate invocation inputs before submit
if chaincodeName == "" || txArgs == nil {
    return fmt.Errorf("invalid invocation: chaincode=%q args=%v", chaincodeName, txArgs)
}

Type guard

func IsTransactionExecutionError(err error) bool {
	return err != nil && strings.Contains(err.Error(), "failed to execute transaction")
}

Try / catch

try {
    await contract.submitTransaction("createAsset", "a1");
} catch (e) {
    if (String(e).includes("failed to execute transaction")) {
        // unwrap the cause in e.details / peer logs; handle chaincode vs launch failure differently
        console.error("tx failed, cause:", e.details);
    }
    throw e;
}

Prevention

When it happens

Trigger: Any error from ChaincodeSupport.Invoke during Execute/ExecuteLegacyInit: chaincode launch failure (see error 391), failed authentication of the chaincode stream, chaincode returned an ERROR message, or the transaction timed out waiting for the chaincode response.

Common situations: Endorsement failures surfacing as transaction execution errors when the chaincode logic returns an error; chaincode container unavailable/crashed; transaction timed out because chaincode was slow to start (cold start); wrong arguments causing chaincode panic or error response.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/2aff2eab4d7799ab. Report an issue: GitHub.