BatchCompletedWithErrors

Event Re-added v216 → v247, v252 → v265, v273 → v277, v290 → v315, v320 → v326, v334 → v367, v372 → v377, v385 → current #87

Emitted when a batch operation completes but some items failed.

View events on chain
Useful for: validatorsdevelopersanalytics

The Big Picture

Not every batch operation is all-or-nothing. Some complete partially - some items succeed, others fail. This event signals that your batch finished but had problems. It's a yellow flag: mostly worked, but check the details. Pair with BatchWeightItemFailed events to understand exactly what failed and why.

Why This Matters

A batch that partially fails is worse than one that completely fails (which you'd notice immediately). This event warns you: 'Something went wrong, check the details.' Without this, you might think everything succeeded when actually some subnets didn't get updated.

Example Scenario

You batch weights for 10 subnets. 8 succeed, 2 fail. BatchCompletedWithErrors fires, signaling partial failure. You check BatchWeightItemFailed events and see subnets 5 and 9 failed (rate limited and not registered, respectively). Your automation retries those two specifically.

Common Questions

Is partial success good or bad?
Depends on your needs. Getting 8/10 subnets updated is better than 0/10, but you have incomplete state. Treat as 'needs attention' - review and fix the failures.
How do I know which items succeeded vs failed?
Look for BatchWeightItemFailed events for failures. Items without failure events succeeded. You can also check each subnet's weight state directly.
Should I retry the whole batch or just failures?
Just the failures. Retrying succeeded items wastes resources and might hit rate limits. Build retry logic that targets specific failed items.

Use Cases

  • Detect partial batch success/failure
  • Trigger follow-up actions for failed items
  • Track batch reliability metrics
  • Build robust batch operation handling

How to Use This Event

  • Monitor for partial batch failures
  • Build alerting for mixed success/failure batches
  • Track success rates across batch operations

From Chain Metadata

A batch extrinsic completed but with some errors.

Triggers

Preconditions

  • Batch operation executed
  • At least one item failed

Effects

Postconditions

  • Successful items applied
  • Failed items skipped

Side Effects

  • Check BatchWeightItemFailed for specific errors

This event has no data fields.

Code Examples

import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";

const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });

// Subscribe to BatchCompletedWithErrors events
api.query.system.events((events) => {
  events
    .filter(({ event }) =>
      event.section === stringCamelCase("SubtensorModule") &&
      event.method === "BatchCompletedWithErrors"
    )
    .forEach(({ event }) => {
      console.log("BatchCompletedWithErrors:", event.data.toHuman());
    });
});

Version History

v216 block 4,510,996 0 args
v252 block 5,163,656 0 args
v273 block 5,659,032 0 args
v290 block 5,947,548 0 args
v320 block 6,523,566 0 args
v334 block 6,811,690 0 args
v372 block 7,430,358 0 args
v385 block 7,782,670 0 args Current

Runtime Info

View Source
Pallet Index
7
Event Index
87
First Version
v216
Current Version
v393