lukeed/uvu

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

rictic opened this issue · 0 comments

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!