refactor(process): use dedicated CommandLaneClearedError in clearCommandLane

Replace bare `new Error("Command lane cleared")` with a dedicated
`CommandLaneClearedError` class so callers that fire-and-forget
enqueued tasks can catch this specific type and avoid surfacing
unhandled rejection warnings.
This commit is contained in:
Yi LIU
2026-02-14 01:43:33 +08:00
committed by Peter Steinberger
parent a49dd83b14
commit a5ccfa57a8
2 changed files with 14 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ vi.mock("../logging/diagnostic.js", () => ({
import {
clearCommandLane,
CommandLaneClearedError,
enqueueCommand,
enqueueCommandInLane,
getActiveTaskCount,
@@ -218,7 +219,7 @@ describe("command queue", () => {
expect(removed).toBe(1); // only the queued (not active) entry
// The queued promise should reject.
await expect(second).rejects.toThrow("Command lane cleared");
await expect(second).rejects.toBeInstanceOf(CommandLaneClearedError);
// Let the active task finish normally.
resolve1();