Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 13, 2025

  • Investigate the bun test shim timeout parameter handling
  • Identify issues in the code
  • Fix the timeout clearTimeout bug (timeoutId can be 0)
  • Fix timeout value handling (0 and negative values)
  • Remove unnecessary try-catch block
  • Add timeout edge case tests to test suite
  • Add longer execution timeout test (7s with 10s timeout)
  • Fix Bun native timeout integration
  • Fix Node.js shim timeout handling
  • Verify fixes with Deno tests
  • Format code
  • Run code review
  • Run security check

Investigation Summary

Issues Fixed:

  1. clearTimeout bug (Critical): Changed if (timeoutId) to if (timeoutId !== -1) to properly handle when setTimeout returns 0
  2. Timeout value 0 handling: Added explicit && options.timeout > 0 check to treat 0 and negative values as "no timeout"
  3. Unnecessary try-catch: Removed empty catch block
  4. Bun native timeout integration: Fixed Bun shim to pass timeout option to Bun's native test runner
  5. Node.js timeout validation: Updated Node.js shim to filter out invalid timeout values (0 and negative) that Node.js doesn't accept
  6. All shims fixed: Applied appropriate fixes to bun.ts, deno.ts, and node.ts

Test Coverage Added:

  • Test with timeout = 0 (treated as no timeout)
  • Test with negative timeout (treated as no timeout)
  • Test with generous timeout (5s)
  • Test with 7 second execution and 10 second timeout (passes)

Node.js Fix:

Node.js requires timeout to be > 0 and <= 2147483647. Updated transformOptions to only pass valid positive timeout values to Node's test runner, preventing "test timed out after 0ms" and "ERR_OUT_OF_RANGE" errors.

Original prompt

investigate if the bun test shim properly habdle the timeout parameter


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 13, 2025 13:15
Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate bun test shim handling of timeout parameter Fix timeout clearTimeout bug and edge case handling in bun/deno shims Dec 13, 2025
Copilot AI requested a review from Hexagon December 13, 2025 13:19
@Hexagon
Copy link
Member

Hexagon commented Dec 13, 2025

@copilot test longer executions, like 7 second execution timing out after 6 seconds, and 7 second executions completing with 10 second timeout

Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 13, 2025

@copilot test longer executions, like 7 second execution timing out after 6 seconds, and 7 second executions completing with 10 second timeout

Added test for 7 second execution with 10 second timeout (passes). Also validated 7 second execution with 6 second timeout (times out correctly). Both scenarios work as expected in Deno and Bun. Fixed Bun shim to pass timeout to native test runner. (02eb2d2)

@Hexagon
Copy link
Member

Hexagon commented Dec 13, 2025

.

@Hexagon
Copy link
Member

Hexagon commented Dec 13, 2025

@copilot New tests failing in node

ok 14 - Three-Level Nesting with Mixed Operations

duration_ms: 20.581975
...

Subtest: Test with timeout = 0 (no timeout)

not ok 15 - Test with timeout = 0 (no timeout)

duration_ms: 2.163614
location: '/home/runner/work/test/test/shims/node.ts:1:589'
failureType: 'testTimeoutFailure'
error: 'test timed out after 0ms'
code: 'ERR_TEST_FAILURE'
...

Subtest: Test completes within generous timeout

ok 16 - Test completes within generous timeout

duration_ms: 50.214306
...

Subtest: 7 second execution with 10 second timeout

ok 17 - 7 second execution with 10 second timeout

duration_ms: 7001.965407
...

Error: A resource generated asynchronous activity after the test ended. This activity created the error "RangeError [ERR_OUT_OF_RANGE]: The value of "options.timeout" is out of range. It must be >= 0 && <= 2147483647. Received -100" which triggered an unhandledRejection event, caught by the test runner.

1..17

Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 13, 2025

@copilot New tests failing in node

ok 14 - Three-Level Nesting with Mixed Operations
...

Fixed Node.js shim to filter out invalid timeout values (0 and negative). Node.js requires timeout > 0, so now these edge case tests won't pass invalid values to Node's test runner. (cbce133)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • npm.jsr.io
    • Triggering command: /opt/hostedtoolcache/node/24.11.1/x64/bin/node node /opt/hostedtoolcache/node/24.11.1/x64/bin/npm install @std/assert@npm:@jsr/std__assert @std/async@npm:@jsr/std__async @cross/runtime@npm:@jsr/cross__runtime (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Hexagon Hexagon marked this pull request as ready for review December 13, 2025 16:59
@Hexagon Hexagon merged commit 6f65ade into main Dec 13, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants