moeru-ai/airi · warning · Error
Player not found, stopped following
Error message
Player not found, stopped following
What it means
Thrown inside followPlayer() in the FollowCommand plugin. On each tick where state.following is set, it reads bot.bot.players[username]?.entity. If the followed player's entity is gone (player logged off, moved out of render distance, or despawned), it clears state.following and throws. The throw propagates out of the tick handler, so the follow silently stops (state cleared) and the error surfaces in the tick error path.
Source
Thrown at integrations/minecraft/src/plugins/follow.ts:37
state.following = username
logger.withFields({ username }).log('Starting to follow player')
followPlayer()
}
function stopFollow(): void {
state.following = undefined
logger.log('Stopping follow')
bot.bot.pathfinder.stop()
}
function followPlayer(): void {
if (!state.following)
return
const target = bot.bot.players[state.following]?.entity
if (!target) {
state.following = undefined
throw new Error('Player not found, stopped following')
}
const { x: playerX, y: playerY, z: playerZ } = target.position
bot.bot.pathfinder.setMovements(state.movements)
bot.bot.pathfinder.setGoal(new goals.GoalNear(playerX, playerY, playerZ, options?.rangeGoal ?? 1))
}
bot.onCommand('follow', (ctx) => {
const username = ctx.command!.sender
if (!username) {
throw new Error('Please specify a player name!')
}
startFollow(username)
})
bot.onCommand('stop', () => {View on GitHub (pinned to 27111382b4)
Solutions
- Wrap the follow command call (or the tick handler) in try/catch to report 'lost player' gracefully instead of an uncaught throw.
- Re-issue 'follow <name>' once the player is back in range.
- Check bot.players[name]?.entity existence before starting follow.
- Consider periodic re-validation and a cooldown before clearing the target.
Example fix
// before
// function followPlayer(): void {
// const target = bot.bot.players[state.following]?.entity
// if (!target) {
// state.following = undefined
// throw new Error('Player not found, stopped following')
// }
// ...
// }
//
// after
// function followPlayer(): void {
// const target = bot.bot.players[state.following]?.entity
// if (!target) {
// state.following = undefined
// logger.log(`Stopped following: target no longer visible`)
// return
// }
// ...
// } Defensive patterns
Strategy: try-catch
Validate before calling
// Guard the follow target before relying on it each tick:
// const target = bot.bot.players[state.following]?.entity
// if (!target) { state.following = undefined; logger.log('follow target lost'); return } Type guard
function hasEntity(p: unknown): p is { entity: object } {
return !!p && typeof p === 'object' && !!(p as any).entity
} Try / catch
// Wrap the follow tick so a lost target does not crash the tick loop:
// try { followPlayer() }
// catch (e) { logger.log('follow error:', errorMessageFrom(e)) } Prevention
- Validate bot.players[name]?.entity before starting follow.
- Handle target logout/dimension-change gracefully (log instead of throw).
- Re-issue 'follow <name>' once the player re-enters range.
- Add a cooldown before clearing a transiently-lost target.
When it happens
Trigger: The followed player disconnects from the server; the player moves beyond the server's entity tracking radius so bot.players[name].entity becomes undefined; the player enters a different dimension; the player is far enough that the server stops sending entity data.
Common situations: Long follow sessions where the target logs out; target teleporting across dimensions; target using /vanish or similar; high-latency connection dropping entity updates.
Related errors
- Please specify a player name!
- can't find player ${username}, maybe they're too far away?
- Unknown action: ${step.tool}
- RESOURCE_MISSING
- TARGET_NOT_FOUND
AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12).
Data as JSON: /api/errors/4a5b7dca15f88c59.
Report an issue: GitHub.