fix(process): reject pending promises when clearing command lane

clearCommandLane() was truncating the queue array without calling
resolve/reject on pending entries, causing never-settling promises
and memory leaks when upstream callers await enqueueCommandInLane().

Splice entries and reject each before clearing so callers can handle
the cancellation gracefully.
This commit is contained in:
Yi LIU
2026-02-14 01:26:05 +08:00
committed by Peter Steinberger
parent f7e2b8ff5f
commit a49dd83b14
2 changed files with 34 additions and 1 deletions

View File

@@ -162,7 +162,10 @@ export function clearCommandLane(lane: string = CommandLane.Main) {
return 0;
}
const removed = state.queue.length;
state.queue.length = 0;
const pending = state.queue.splice(0);
for (const entry of pending) {
entry.reject(new Error("Command lane cleared"));
}
return removed;
}