From 1f66d0bfbc490fef78c54df5710b14834238abc8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Dec 2025 13:08:23 +0000 Subject: [PATCH 1/5] Initial plan From 2ba1216f249e65c3b2e23f327df3d16ec69f9a01 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Dec 2025 13:15:21 +0000 Subject: [PATCH 2/5] Fix timeout parameter handling in bun and deno shims Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- mod.test.ts | 18 ++++++++++++++++++ shims/bun.ts | 6 ++---- shims/deno.ts | 6 ++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/mod.test.ts b/mod.test.ts index d142617..97325b3 100644 --- a/mod.test.ts +++ b/mod.test.ts @@ -250,3 +250,21 @@ test("Three-Level Nesting with Mixed Operations", async (context) => { assertEquals(executionCount, 4); }); + +// Test timeout with zero value (should be treated as no timeout) +test("Test with timeout = 0 (no timeout)", async () => { + await delay(50); + assertEquals(1, 1); +}, { timeout: 0 }); + +// Test timeout with negative value (should be treated as no timeout) +test("Test with negative timeout (no timeout)", async () => { + await delay(50); + assertEquals(1, 1); +}, { timeout: -100 }); + +// Test that completes well within timeout +test("Test completes within generous timeout", async () => { + await delay(50); + assertEquals(1, 1); +}, { timeout: 5000 }); diff --git a/shims/bun.ts b/shims/bun.ts index 581d87a..afc0c55 100644 --- a/shims/bun.ts +++ b/shims/bun.ts @@ -87,7 +87,7 @@ export async function wrappedTest( }); let timeoutId: number = -1; // Store the timeout ID try { - if (options.timeout) { + if (options.timeout && options.timeout > 0) { const timeoutPromise = new Promise((_, reject) => { timeoutId = setTimeout(() => { reject(new Error("Test timed out")); @@ -98,10 +98,8 @@ export async function wrappedTest( // No timeout, just await testFn await options.waitForCallback ? callbackPromise : testFnPromise; } - } catch (error) { - throw error; } finally { - if (timeoutId) clearTimeout(timeoutId); + if (timeoutId !== -1) clearTimeout(timeoutId); // Make sure testFnPromise has completed await testFnPromise; if (options.waitForCallback) await callbackPromise; diff --git a/shims/deno.ts b/shims/deno.ts index 8828f4e..d988aae 100644 --- a/shims/deno.ts +++ b/shims/deno.ts @@ -114,7 +114,7 @@ export function wrappedTest(name: string, testFn: TestSubject, options: WrappedT }); let timeoutId: number = -1; // Store the timeout ID try { - if (options.timeout) { + if (options.timeout && options.timeout > 0) { const timeoutPromise = new Promise((_, reject) => { timeoutId = setTimeout(() => { reject(new Error("Test timed out")); @@ -124,10 +124,8 @@ export function wrappedTest(name: string, testFn: TestSubject, options: WrappedT } else { await options.waitForCallback ? callbackPromise : testFnPromise; } - } catch (error) { - throw error; } finally { - if (timeoutId) clearTimeout(timeoutId); + if (timeoutId !== -1) clearTimeout(timeoutId); await testFnPromise; if (options.waitForCallback) await callbackPromise; } From 11f062005be064f86c2b44c52fe4931402bf212b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Dec 2025 13:16:22 +0000 Subject: [PATCH 3/5] Format code with deno fmt Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- mod.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod.test.ts b/mod.test.ts index 97325b3..c80b9f2 100644 --- a/mod.test.ts +++ b/mod.test.ts @@ -257,7 +257,7 @@ test("Test with timeout = 0 (no timeout)", async () => { assertEquals(1, 1); }, { timeout: 0 }); -// Test timeout with negative value (should be treated as no timeout) +// Test timeout with negative value (should be treated as no timeout) test("Test with negative timeout (no timeout)", async () => { await delay(50); assertEquals(1, 1); From 02eb2d20f16d3749823c8263196a3a7c02d5c437 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Dec 2025 13:32:16 +0000 Subject: [PATCH 4/5] Add longer timeout tests and fix Bun native timeout integration Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- mod.test.ts | 6 ++++++ shims/bun.ts | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/mod.test.ts b/mod.test.ts index c80b9f2..3d2610d 100644 --- a/mod.test.ts +++ b/mod.test.ts @@ -268,3 +268,9 @@ test("Test completes within generous timeout", async () => { await delay(50); assertEquals(1, 1); }, { timeout: 5000 }); + +// Test longer execution with sufficient timeout (7 seconds with 10 second timeout) +test("7 second execution with 10 second timeout", async () => { + await delay(7000); + assertEquals(1, 1); +}, { timeout: 10000 }); diff --git a/shims/bun.ts b/shims/bun.ts index afc0c55..7191cdf 100644 --- a/shims/bun.ts +++ b/shims/bun.ts @@ -6,6 +6,19 @@ export async function wrappedTest( testFn: TestSubject, options: WrappedTestOptions, ): Promise { + // Build Bun test options - pass timeout to Bun's native test runner + // If timeout is 0 or not specified, Bun will use its default 5s timeout + // If we're using custom timeout logic, we need to set a high value for Bun + const bunOptions: { timeout?: number; skip?: boolean } = { + skip: options?.skip || false, + }; + + // If a timeout is specified and > 0, pass it to Bun's native timeout + // This makes Bun's timeout and our custom timeout work together + if (options.timeout && options.timeout > 0) { + bunOptions.timeout = options.timeout; + } + return await test(name, async () => { // Create wrapped context with step method const wrappedContext: TestContext = { @@ -104,5 +117,5 @@ export async function wrappedTest( await testFnPromise; if (options.waitForCallback) await callbackPromise; } - }); + }, bunOptions); } From cbce13347849dbfeca8a6dc6798fa8e40c27b7f4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Dec 2025 16:19:11 +0000 Subject: [PATCH 5/5] Fix Node.js shim to handle timeout edge cases (0 and negative values) Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- shims/node.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/shims/node.ts b/shims/node.ts index 92fab76..651f622 100644 --- a/shims/node.ts +++ b/shims/node.ts @@ -3,10 +3,17 @@ import type { ContextStepFunction, SimpleStepFunction, StepOptions, StepSubject, import type { TestSubject } from "../mod.ts"; function transformOptions(options?: WrappedTestOptions) { - return { + const nodeOptions: { skip: boolean; timeout?: number } = { skip: options?.skip || false, - timeout: options?.timeout, }; + + // Node.js requires timeout to be > 0 and <= 2147483647 + // Only set timeout if it's a valid positive number + if (options?.timeout && options.timeout > 0) { + nodeOptions.timeout = options.timeout; + } + + return nodeOptions; } // Helper function to create a fallback context for older Node versions