





























@@ -365,17 +365,17 @@ describe("createLazyChannelApprovalNativeRuntimeAdapter", () => {
365365expect(load).toHaveBeenCalledTimes(1);
366366});
367367368-it("unbinds in-flight wrapped entry when stop() fires between deliverPending and bindPending", async () => {
369-const deliverGate = { resolve: () => {}, promise: Promise.resolve() };
370-const deliverPromise = new Promise<void>((resolve) => {
371-deliverGate.resolve = resolve;
368+it("unbinds in-flight wrapped entry when stop() fires between bindPending and activeEntries.set", async () => {
369+const bindGate = { resolve: () => {}, promise: Promise.resolve() };
370+const bindPromise = new Promise<void>((resolve) => {
371+bindGate.resolve = resolve;
372372});
373-deliverGate.promise = deliverPromise;
374-const deliverPending = vi.fn(async () => {
375-await deliverPromise;
376-return { messageId: "in-flight" };
373+bindGate.promise = bindPromise;
374+const deliverPending = vi.fn().mockResolvedValue({ messageId: "in-flight" });
375+const bindPending = vi.fn(async () => {
376+await bindPromise;
377+return { bindingId: "bound-in-flight" };
377378});
378-const bindPending = vi.fn().mockResolvedValue({ bindingId: "bound-in-flight" });
379379const unbindPending = vi.fn();
380380381381const runtime = await createTestApprovalHandler(
@@ -389,19 +389,21 @@ describe("createLazyChannelApprovalNativeRuntimeAdapter", () => {
389389const request = makeExecApprovalRequest("exec:in-flight");
390390391391const inflight = approvalRuntime.handleRequested(request);
392+// microtasks 흘려 deliverPending 완료 + bindPending await 진입.
393+await new Promise((r) => setTimeout(r, 0));
392394await new Promise((r) => setTimeout(r, 0));
393395394-// stop() while deliverPending is parked — onStopped flips the closure flag.
396+// stop() — onStopped 가 stopped flag set. bindPending 은 park.
395397await approvalRuntime.stop();
396-deliverGate.resolve();
398+bindGate.resolve();
397399await inflight;
398400399401expect(unbindPending).toHaveBeenCalledTimes(1);
400402const unbind = firstCallArg(unbindPending) as
401403| { entry?: unknown; binding?: unknown; request?: unknown }
402404| undefined;
403405expect(unbind?.entry).toEqual({ messageId: "in-flight" });
406+expect(unbind?.binding).toEqual({ bindingId: "bound-in-flight" });
404407expect(unbind?.request).toBe(request);
405-expect(bindPending).not.toHaveBeenCalled();
406408});
407409});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。