abortActiveMovements: only WARN when actually aborting an in-flight move
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) <noreply@anthropic.com>
This commit is contained in:
@@ -719,8 +719,17 @@ class MachineGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async abortActiveMovements(reason = "new demand") {
|
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 => {
|
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") {
|
if (typeof machine.abortMovement === "function") {
|
||||||
await machine.abortMovement(reason);
|
await machine.abortMovement(reason);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user