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

A garbage collected async test causes uvu to silently exit with success #206

Closed
rictic opened this issue May 2, 2022 · 0 comments · Fixed by #207
Closed

A garbage collected async test causes uvu to silently exit with success #206

rictic opened this issue May 2, 2022 · 0 comments · Fixed by #207

Comments

@rictic
Copy link
Contributor

rictic commented May 2, 2022

Consider some (slightly contrived) code like:

test('math', async () => {
  await new Promise((resolve) => {
    if (1 + 1 === 3) {
      resolve(3);
    }
  });
  assert.equal(2 * 2, 5);
});

The promise never resolves (because 1+1 isn't 3), and the VM can garbage collect not only the Promise executor, but also the resolve function (because nothing references it), and from there, surprisingly, it can garbage collect everything because the test of the node process is just waiting on a promise that will never resolve. So the process exits with exit code 0 in the middle of testing!

rictic added a commit to rictic/uvu that referenced this issue May 2, 2022
Fixes lukeed#206

Also fixes the case where a test calls process.exit(0) itself, as that's essentially the same thing.
rictic added a commit to rictic/uvu that referenced this issue May 2, 2022
Fixes lukeed#206

Also fixes the case where a test calls process.exit(0) itself, as that's essentially the same thing.
lukeed added a commit that referenced this issue Jul 3, 2022
…ises (#207)

* A test that exits early should fail

Fixes #206

Also fixes the case where a test calls process.exit(0) itself, as that's essentially the same thing.

* Apply suggestions from code review

* wrap exit listener; merge test files

Co-authored-by: Luke Edwards <luke.edwards05@gmail.com>
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 a pull request may close this issue.

1 participant