Dashboard sipadu mbip
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

test-forever.js 515B

123456789101112131415161718192021222324
  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. })();