moeru-ai/airi · error · Error

Failed to reach ${blockType}: ${result.reason} — ${result.me

Error message

Failed to reach ${blockType}: ${result.reason} — ${result.message}

What it means

Thrown by goToNearestBlock after getNearestBlock succeeds but the subsequent goToPosition returns result.ok === false. The wrapped PathfindResult carries a reason of 'timeout' | 'stagnation' | 'noPath' | 'error' | 'interrupted' and a human-readable message. This is a plain Error; the failure is in pathfinding execution, not block discovery.

Source

Thrown at integrations/minecraft/src/skills/movement.ts:111

  blockType: string,
  minDistance = 2,
  range = 64,
): Promise<Block> {
  const MAX_RANGE = 512
  if (range > MAX_RANGE) {
    log(mineflayer, `Maximum search range capped at ${MAX_RANGE}.`)
    range = MAX_RANGE
  }

  const block = getNearestBlock(mineflayer, blockType, range)
  if (!block) {
    throw new Error(`Could not find any ${blockType} in ${range} blocks.`)
  }

  log(mineflayer, `Found ${blockType} at ${block.position}.`)
  const result = await goToPosition(mineflayer, block.position.x, block.position.y, block.position.z, minDistance)
  if (!result.ok) {
    throw new Error(`Failed to reach ${blockType}: ${result.reason} — ${result.message}`)
  }
  return block
}

export async function goToNearestEntity(
  mineflayer: Mineflayer,
  entityType: string,
  minDistance = 2,
  range = 64,
): Promise<boolean> {
  const entity = getNearestEntityWhere(
    mineflayer,
    entity => entity.name === entityType,
    range,
  )

  if (!entity) {
    log(mineflayer, `Could not find any ${entityType} in ${range} blocks.`)

View on GitHub (pinned to 27111382b4)

Solutions

  1. Inspect result.reason — for 'noPath', clear obstacles or pick a closer target; for 'stagnation'/'timeout', retry after moving the bot; for 'interrupted', avoid concurrent navigation calls.
  2. Break/bridge toward the target manually before re-running goToNearestBlock.
  3. Increase minDistance so the goal is satisfied from a reachable adjacent position.
  4. Retry once — transient stagnation/timeout often resolves on a second attempt.

Example fix

// before
const block = await goToNearestBlock(mineflayer, 'oak_log', 2, 64)

// after — handle PathfindResult failure explicitly
try {
  const block = await goToNearestBlock(mineflayer, 'oak_log', 2, 64)
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Failed to reach')) {
    // mine toward target or pick another, then retry
  }
  throw e
}
Defensive patterns

Strategy: retry

Type guard

function isNavigationFailedError(e: unknown): boolean {
  return e instanceof Error && /Failed to reach .*:/.test(e.message)
}

Try / catch

try {
  return await goToNearestBlock(mineflayer, blockType, minDistance, range)
} catch (e) {
  if (e instanceof Error && /Failed to reach/.test(e.message)) {
    // parse reason: noPath -> break/bridge; stagnation/timeout -> retry once
    await sleep(2000)
    return await goToNearestBlock(mineflayer, blockType, minDistance, range)
  }
  throw e
}

Prevention

When it happens

Trigger: The target block is found but the pathfinder cannot reach it: terrain blocks the path (noPath), the bot stops making progress for ~15s (stagnation), the goal exceeds the time estimate (timeout), a navigation interrupt is signalled, or pathfinding throws internally (error).

Common situations: Target is across a wall, ravine, or unbreakable blocks; bot is stuck in a hole or against an obstacle; server lag stalls movement so stagnation triggers; another action interrupted navigation; the goal coordinates are unreachable (floating island, lava-locked).

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/fa698d8040c8c923. Report an issue: GitHub.