From 2651aaf409503d50bea3e471635307c5aa7a5847 Mon Sep 17 00:00:00 2001 From: Rene De Ren Date: Sat, 9 May 2026 09:43:12 +0200 Subject: [PATCH] abortActiveMovements: only WARN when actually aborting an in-flight move MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In normal operation the _dispatchInFlight gate (handleInput) guarantees no pump movement is in flight when a new dispatch starts, so the per-machine abort call is a no-op. The previous unconditional WARN flooded the log with one line per pump per tick (~3/s) for what was actually a normal-path no-op. Now the WARN fires ONLY when a pump's state is accelerating or decelerating — i.e. the gate has been bypassed and we're force- aborting an in-flight ramp. The wording reflects that: Force-aborting in-flight movement on pump_a (state=accelerating) due to: new demand received — _dispatchInFlight gate bypassed. If you ever see this in production logs, the gate has a hole and needs investigating. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/specificClass.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/specificClass.js b/src/specificClass.js index 2979856..99b697d 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -719,8 +719,17 @@ class MachineGroup { } async abortActiveMovements(reason = "new demand") { + // Safety net: in normal operation the _dispatchInFlight gate + // (handleInput) ensures no pump movement is in flight when a + // new dispatch starts, so this is a no-op. If a pump IS still + // moving here, the gate was bypassed (direct call to + // abortActiveMovements, mode change racing a dispatch, etc.) — + // surface that loudly so the bypass can be diagnosed. + const movementStates = new Set(['accelerating', 'decelerating']); await Promise.all(Object.values(this.machines).map(async machine => { - this.logger.warn(`Aborting active movements for machine ${machine.config.general.id} due to: ${reason}`); + const state = machine.state?.getCurrentState?.(); + if (!movementStates.has(state)) return; + this.logger.warn(`Force-aborting in-flight movement on ${machine.config.general.id} (state=${state}) due to: ${reason} — _dispatchInFlight gate bypassed.`); if (typeof machine.abortMovement === "function") { await machine.abortMovement(reason); }