devlato / async-wait-until

Waits for an expectation to be truthy. A small library with a convenient API suitable for unit and integration testing
https://devlato.github.io/async-wait-until/
MIT License
75 stars 13 forks source link

waitUntil throws exception however keeps on running the predicate #14

Closed johnjiang closed 3 years ago

johnjiang commented 3 years ago

Describe the bug When I use a predicate with a timeout and interval, an exception is correctly thrown after the timeout but the predicate is still being executed.

To Reproduce https://codesandbox.io/s/vigilant-dust-c3119?file=/src/index.js

import { waitUntil } from "async-wait-until";

(() => {
  waitUntil(
    () => {
      console.log("Trying");
      return Promise.resolve(false);
    },
    { timeout: 1000, intervalBetweenAttempts: 100 }
  );
})();

Expected behavior Exception is thrown and the predicate no longer runs. However, the exception is thrown but the predicate is still being executed

devlato commented 3 years ago

Thanks for reporting @johnjiang! I'll publish the fix shortly.

johnjiang commented 3 years ago

Thanks for fixing it so quickly!

devlato commented 3 years ago

No worries!