deno icon indicating copy to clipboard operation
deno copied to clipboard

fix(ext/node/polyfills): New async setInterval function to improve the nodejs compatibility

Open 0hmX opened this issue 1 year ago • 1 comments

#26499

This PR adds a better implementation of setInterval using async functions, similar to the one in Node.js. It's mostly based on the Node.js version, with some updates to error handling and logic.

The PR is complete, but I need help with:

  • Running a single test file
  • Deciding where to place my test files

Currently, I have a test to validate my code, but I’m running it outside of cargo test because running all tests at once is frustrating and often causes my system to freeze due to high memory use. This issue occurred even before my changes.

0hmX avatar Nov 03 '24 19:11 0hmX

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 03 '24 19:11 CLAassistant

Thanks for the PR!

Deciding where to place my test files

I would recommend adding your test as a unit test to this file: https://github.com/denoland/deno/blob/770ef1460085e1a1b706cc7f066e7b3ea5010eb0/tests/unit_node/timers_test.ts#L102-L110

Running a single test file

Assuming you've added your test to tests/unit_node/timers_test.ts, you can run that file one of two ways:

  • With cargo
     cargo test node_unit_tests::timers_test
    
    this will execute all of the unit tests in timers_test.ts
  • You can also build deno with cargo build and then run the tests using the binary, so
    cargo build
    ./target/debug/deno test -A --config tests/config/deno.json tests/unit_node/timers_test.ts
    
    that will run the tests with a normal deno test, so you can filter specific tests within that file like you normally would

nathanwhit avatar Nov 05 '24 19:11 nathanwhit

@nathanwhit I've moved the test to the appropriate directory, so the PR should be ready for merging. Please take a look when you can. Also, thanks for the tip about running directly from the target directory—it made things a lot easier!

0hmX avatar Nov 07 '24 04:11 0hmX