test-forever.js 515 B

12345678910111213141516171819202122232425
  1. var common = require('../common');
  2. var assert = common.assert;
  3. var retry = require(common.dir.lib + '/retry');
  4. (function testForeverUsesFirstTimeout() {
  5. var operation = retry.operation({
  6. retries: 0,
  7. minTimeout: 100,
  8. maxTimeout: 100,
  9. forever: true
  10. });
  11. operation.attempt(function(numAttempt) {
  12. console.log('>numAttempt', numAttempt);
  13. var err = new Error("foo");
  14. if (numAttempt == 10) {
  15. operation.stop();
  16. }
  17. if (operation.retry(err)) {
  18. return;
  19. }
  20. });
  21. })();