From 51fefba9b29339b7aa02f8c38c19f0e168174dcf Mon Sep 17 00:00:00 2001 From: HARUYAMA Seigo Date: Mon, 12 Oct 2026 13:45:48 +0900 Subject: [PATCH 1/2] fix(test): restore stubs before defined properties in worker_test sinon 22 restores sandbox fakes in a different order, so the properties added by `sandbox.define()` were removed before the stubs on them were restored, breaking `stubMessage()` and cascading failures in subsequent steps. Use a separate sandbox for `define()` and restore it last. Co-Authored-By: Claude Opus 5.5 --- denops/@denops-private/worker_test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/denops/@denops-private/worker_test.ts b/denops/@denops-private/worker_test.ts index 9fa0ed96..ae1fa870 100644 --- a/denops/@denops-private/worker_test.ts +++ b/denops/@denops-private/worker_test.ts @@ -49,10 +49,13 @@ function stubConsole() { function stubMessage() { const workerGlobal = globalThis as DedicatedWorkerGlobalScope; + // Use separate sandboxes so that stubs are restored before the defined + // properties are removed. + const defineSandbox = sinon.createSandbox(); const sandbox = sinon.createSandbox(); - sandbox.define(workerGlobal, "postMessage", () => {}); + defineSandbox.define(workerGlobal, "postMessage", () => {}); const postMessage = sandbox.stub(workerGlobal, "postMessage"); - sandbox.define(workerGlobal, "onmessage", null); + defineSandbox.define(workerGlobal, "onmessage", null); const onmessage = sandbox.stub(workerGlobal, "onmessage"); const fakeHostMessage = (data: unknown) => { workerGlobal.onmessage?.(new MessageEvent("message", { data })); @@ -64,6 +67,7 @@ function stubMessage() { fakeHostMessage, [Symbol.dispose]() { sandbox.restore(); + defineSandbox.restore(); }, }; } From ea1c4cf65b2feab7223837d4c03d250d82c985de Mon Sep 17 00:00:00 2001 From: HARUYAMA Seigo Date: Mon, 12 Oct 2026 13:53:00 +0900 Subject: [PATCH 2/2] fix(test): check timeout error name instead of message in shared_server_test The message of the `AbortSignal.timeout()` error changed in recent Deno ("Signal timed out" -> "The operation was aborted due to timeout"). Check that a `DOMException` named `TimeoutError` is thrown instead, so the test passes regardless of the Deno version. Co-Authored-By: Claude Opus 5.5 --- tests/denops/testutil/shared_server_test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/denops/testutil/shared_server_test.ts b/tests/denops/testutil/shared_server_test.ts index 1e3ac894..ddc8f1f1 100644 --- a/tests/denops/testutil/shared_server_test.ts +++ b/tests/denops/testutil/shared_server_test.ts @@ -107,13 +107,15 @@ Deno.test("useSharedServer()", async (t) => { await t.step("rejects if the server startup times out (flaky)", async () => { await retry(async () => { - await assertRejects( + // NOTE: The message of the timeout error differs between Deno versions, + // so check the error name instead. + const error = await assertRejects( async () => { await using _server = await useSharedServer({ timeout: 0 }); }, - Error, - "Signal timed out", + DOMException, ); + assertEquals(error.name, "TimeoutError"); }); }); });