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

Setting maxTimeout to undefined breaks minTimeout behavior #90

Open
vilaemail opened this issue May 19, 2023 · 0 comments
Open

Setting maxTimeout to undefined breaks minTimeout behavior #90

vilaemail opened this issue May 19, 2023 · 0 comments

Comments

@vilaemail
Copy link

Repro code:

const retry = require('retry');

const testCase = (configAmmend) => {
    return new Promise((resolve) => {
        const op = retry.operation({
            retries: 1,
            minTimeout: 800,
            factor: 1,
            ...configAmmend
        });

        const startTime = Date.now();
        op.attempt((attempt) => {
            console.log(`${attempt}: ${Date.now() - startTime}`);
            op.retry(new Error('fail on purpose'));
            if (attempt === 2) {
                resolve();
            }
        });
    });
};

const test = async () => {
    console.log('test 1');
    await testCase({});
    console.log('test 2');
    await testCase({ maxTimeout: 1000 });
    console.log('test 3');
    await testCase({ maxTimeout: undefined });
}

test();

Expected behavior:

test 1
1: 0
2: 809
test 2
1: 0
2: 810
test 3
1: 0
2: 809

Actual behavior:

test 1
1: 0
2: 809
test 2
1: 0
2: 810
test 3
1: 0
2: 15
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

No branches or pull requests

1 participant