From ecbfa28f3c7dc9e9371f3214990a249f15ad17a3 Mon Sep 17 00:00:00 2001 From: Yuriy Mayatnikov Date: Tue, 26 May 2026 14:26:34 +0300 Subject: [PATCH] fix(runtime/actions): cancel timed-out log collection --- runtime/actions.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runtime/actions.js b/runtime/actions.js index 5dd0c3a..a44c835 100644 --- a/runtime/actions.js +++ b/runtime/actions.js @@ -410,6 +410,14 @@ export async function chopNearestTree(bot) { return { ok: true, detail: { logType: log.name, at: targetPos } }; } catch (e) { warn("action", `chop failed: ${e.message}`); + // Promise.race timeouts do not cancel mineflayer-collectblock; an old + // collect task can keep owning pathfinder and make every retry time out. + try { + await withTimeout(bot.collectBlock?.cancelTask?.() ?? Promise.resolve(), 2_000, "cancelCollectLog"); + } catch (cancelErr) { + warn("action", `chop cancel failed: ${cancelErr.message}`); + try { bot.pathfinder?.stop?.(); } catch {} + } blacklist.set(key, Date.now() + BLACKLIST_TTL_MS); return { ok: false, detail: e.message, blacklisted: targetPos }; }