






















@@ -25,7 +25,6 @@ type CommandQueueModule = typeof import("./command-queue.js");
2525let clearCommandLane: CommandQueueModule["clearCommandLane"];
2626let CommandLaneClearedError: CommandQueueModule["CommandLaneClearedError"];
2727let CommandLaneTaskTimeoutError: CommandQueueModule["CommandLaneTaskTimeoutError"];
28-let enqueueCommand: CommandQueueModule["enqueueCommand"];
2928let enqueueCommandInLane: CommandQueueModule["enqueueCommandInLane"];
3029let GatewayDrainingError: CommandQueueModule["GatewayDrainingError"];
3130let getActiveTaskCount: CommandQueueModule["getActiveTaskCount"];
@@ -69,7 +68,7 @@ function enqueueBlockedMainTask<T = void>(
6968release: () => void;
7069} {
7170const deferred = createDeferred();
72-const task = enqueueCommand(async () => {
71+const task = enqueueCommandInLane(CommandLane.Main, async () => {
7372await deferred.promise;
7473return (await onRelease?.()) as T;
7574});
@@ -98,7 +97,6 @@ describe("command queue", () => {
9897 clearCommandLane,
9998 CommandLaneClearedError,
10099 CommandLaneTaskTimeoutError,
101- enqueueCommand,
102100 enqueueCommandInLane,
103101 GatewayDrainingError,
104102 getActiveTaskCount,
@@ -152,9 +150,9 @@ describe("command queue", () => {
152150};
153151154152const results = await Promise.all([
155-enqueueCommand(makeTask(1)),
156-enqueueCommand(makeTask(2)),
157-enqueueCommand(makeTask(3)),
153+enqueueCommandInLane(CommandLane.Main, makeTask(1)),
154+enqueueCommandInLane(CommandLane.Main, makeTask(2)),
155+enqueueCommandInLane(CommandLane.Main, makeTask(3)),
158156]);
159157160158expect(results).toEqual([1, 2, 3]);
@@ -271,7 +269,7 @@ describe("command queue", () => {
271269});
272270273271it("logs enqueue depth after push", async () => {
274-const task = enqueueCommand(async () => {});
272+const task = enqueueCommandInLane(CommandLane.Main, async () => {});
275273276274expect(diagnosticMocks.logLaneEnqueue).toHaveBeenCalledTimes(1);
277275expect(mockCallArg(diagnosticMocks.logLaneEnqueue, "logLaneEnqueue", 1)).toBe(1);
@@ -286,11 +284,11 @@ describe("command queue", () => {
286284vi.useFakeTimers();
287285try {
288286const blocker = createDeferred();
289-const first = enqueueCommand(async () => {
287+const first = enqueueCommandInLane(CommandLane.Main, async () => {
290288await blocker.promise;
291289});
292290293-const second = enqueueCommand(async () => {}, {
291+const second = enqueueCommandInLane(CommandLane.Main, async () => {}, {
294292warnAfterMs: 5,
295293onWait: (ms, ahead) => {
296294waited = ms;
@@ -784,7 +782,7 @@ describe("command queue", () => {
784782const { task: first, release } = enqueueBlockedMainTask(async () => "first");
785783786784// Second task is queued behind the first.
787-const second = enqueueCommand(async () => "second");
785+const second = enqueueCommandInLane(CommandLane.Main, async () => "second");
788786789787const removed = clearCommandLane();
790788expect(removed).toBe(1); // only the queued (not active) entry
@@ -822,9 +820,9 @@ describe("command queue", () => {
822820823821it("rejects new enqueues with GatewayDrainingError after markGatewayDraining", async () => {
824822markGatewayDraining();
825-await expect(enqueueCommand(async () => "blocked")).rejects.toBeInstanceOf(
826-GatewayDrainingError,
827-);
823+await expect(
824+enqueueCommandInLane(CommandLane.Main, async () => "blocked"),
825+).rejects.toBeInstanceOf(GatewayDrainingError);
828826});
829827830828it("does not affect already-active tasks after markGatewayDraining", async () => {
@@ -837,7 +835,7 @@ describe("command queue", () => {
837835it("resetAllLanes clears gateway draining flag and re-allows enqueue", async () => {
838836markGatewayDraining();
839837resetAllLanes();
840-await expect(enqueueCommand(async () => "ok")).resolves.toBe("ok");
838+await expect(enqueueCommandInLane(CommandLane.Main, async () => "ok")).resolves.toBe("ok");
841839});
842840843841it("migrates legacy queue state missing activeTaskWaiters without crashing", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。