Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cu8code
Copy link

@cu8code cu8code commented Nov 3, 2024

#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.

@CLAassistant
Copy link

CLAassistant commented Nov 3, 2024

CLA assistant check
All committers have signed the CLA.

@cu8code cu8code changed the title fix(ext/node/polyfills): New async setInterval function to improve the nodejs compatibility fix(ext/node): New async setInterval function to improve the nodejs compatibility Nov 5, 2024
@nathanwhit
Copy link
Member

nathanwhit commented Nov 5, 2024

Thanks for the PR!

Deciding where to place my test files

I would recommend adding your test as a unit test to this file:

Deno.test("[node/timers setImmediate returns Immediate object]", () => {
const { clearImmediate, setImmediate } = timers;
const imm = setImmediate(() => {});
imm.unref();
imm.ref();
imm.hasRef();
clearImmediate(imm);
});

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

@cu8code
Copy link
Author

cu8code commented Nov 7, 2024

@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!

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.

3 participants