fix(runtime/actions): cancel timed-out log collection

This commit is contained in:
2026-05-26 14:26:43 +03:00
parent b215d5b2c2
commit ecbfa28f3c
+8
View File
@@ -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 };
}