From f1c6057cd7612e2cf6eedf315a37ddf6f5534dd0 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 22 Jun 2026 15:18:05 +0800 Subject: [PATCH] chore(deadcode): remove unused main-lane queue wrapper --- src/process/command-queue.test.ts | 26 ++++++++++++-------------- src/process/command-queue.ts | 9 +-------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/process/command-queue.test.ts b/src/process/command-queue.test.ts index 663c91892c6e..9e54dc2c9eae 100644 --- a/src/process/command-queue.test.ts +++ b/src/process/command-queue.test.ts @@ -25,7 +25,6 @@ type CommandQueueModule = typeof import("./command-queue.js"); let clearCommandLane: CommandQueueModule["clearCommandLane"]; let CommandLaneClearedError: CommandQueueModule["CommandLaneClearedError"]; let CommandLaneTaskTimeoutError: CommandQueueModule["CommandLaneTaskTimeoutError"]; -let enqueueCommand: CommandQueueModule["enqueueCommand"]; let enqueueCommandInLane: CommandQueueModule["enqueueCommandInLane"]; let GatewayDrainingError: CommandQueueModule["GatewayDrainingError"]; let getActiveTaskCount: CommandQueueModule["getActiveTaskCount"]; @@ -69,7 +68,7 @@ function enqueueBlockedMainTask( release: () => void; } { const deferred = createDeferred(); - const task = enqueueCommand(async () => { + const task = enqueueCommandInLane(CommandLane.Main, async () => { await deferred.promise; return (await onRelease?.()) as T; }); @@ -98,7 +97,6 @@ describe("command queue", () => { clearCommandLane, CommandLaneClearedError, CommandLaneTaskTimeoutError, - enqueueCommand, enqueueCommandInLane, GatewayDrainingError, getActiveTaskCount, @@ -152,9 +150,9 @@ describe("command queue", () => { }; const results = await Promise.all([ - enqueueCommand(makeTask(1)), - enqueueCommand(makeTask(2)), - enqueueCommand(makeTask(3)), + enqueueCommandInLane(CommandLane.Main, makeTask(1)), + enqueueCommandInLane(CommandLane.Main, makeTask(2)), + enqueueCommandInLane(CommandLane.Main, makeTask(3)), ]); expect(results).toEqual([1, 2, 3]); @@ -271,7 +269,7 @@ describe("command queue", () => { }); it("logs enqueue depth after push", async () => { - const task = enqueueCommand(async () => {}); + const task = enqueueCommandInLane(CommandLane.Main, async () => {}); expect(diagnosticMocks.logLaneEnqueue).toHaveBeenCalledTimes(1); expect(mockCallArg(diagnosticMocks.logLaneEnqueue, "logLaneEnqueue", 1)).toBe(1); @@ -286,11 +284,11 @@ describe("command queue", () => { vi.useFakeTimers(); try { const blocker = createDeferred(); - const first = enqueueCommand(async () => { + const first = enqueueCommandInLane(CommandLane.Main, async () => { await blocker.promise; }); - const second = enqueueCommand(async () => {}, { + const second = enqueueCommandInLane(CommandLane.Main, async () => {}, { warnAfterMs: 5, onWait: (ms, ahead) => { waited = ms; @@ -784,7 +782,7 @@ describe("command queue", () => { const { task: first, release } = enqueueBlockedMainTask(async () => "first"); // Second task is queued behind the first. - const second = enqueueCommand(async () => "second"); + const second = enqueueCommandInLane(CommandLane.Main, async () => "second"); const removed = clearCommandLane(); expect(removed).toBe(1); // only the queued (not active) entry @@ -822,9 +820,9 @@ describe("command queue", () => { it("rejects new enqueues with GatewayDrainingError after markGatewayDraining", async () => { markGatewayDraining(); - await expect(enqueueCommand(async () => "blocked")).rejects.toBeInstanceOf( - GatewayDrainingError, - ); + await expect( + enqueueCommandInLane(CommandLane.Main, async () => "blocked"), + ).rejects.toBeInstanceOf(GatewayDrainingError); }); it("does not affect already-active tasks after markGatewayDraining", async () => { @@ -837,7 +835,7 @@ describe("command queue", () => { it("resetAllLanes clears gateway draining flag and re-allows enqueue", async () => { markGatewayDraining(); resetAllLanes(); - await expect(enqueueCommand(async () => "ok")).resolves.toBe("ok"); + await expect(enqueueCommandInLane(CommandLane.Main, async () => "ok")).resolves.toBe("ok"); }); it("migrates legacy queue state missing activeTaskWaiters without crashing", async () => { diff --git a/src/process/command-queue.ts b/src/process/command-queue.ts index b281643bc56d..d8ac9114063f 100644 --- a/src/process/command-queue.ts +++ b/src/process/command-queue.ts @@ -4,8 +4,8 @@ import { logLaneDequeue, logLaneEnqueue, } from "../logging/diagnostic-runtime.js"; -import { clampPositiveTimerTimeoutMs } from "../shared/number-coercion.js"; import { resolveGlobalSingleton } from "../shared/global-singleton.js"; +import { clampPositiveTimerTimeoutMs } from "../shared/number-coercion.js"; import type { CommandQueueEnqueueOptions } from "./command-queue.types.js"; import { CommandLane } from "./lanes.js"; /** @@ -507,13 +507,6 @@ export function enqueueCommandInLane( }); } -export function enqueueCommand( - task: () => Promise, - opts?: CommandQueueEnqueueOptions, -): Promise { - return enqueueCommandInLane(CommandLane.Main, task, opts); -} - export function getQueueSize(lane: string = CommandLane.Main) { const resolved = normalizeLane(lane); const state = getQueueState().lanes.get(resolved);