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

Timeout does not work #4

Closed
Jpunt opened this issue Apr 6, 2016 · 3 comments
Closed

Timeout does not work #4

Jpunt opened this issue Apr 6, 2016 · 3 comments

Comments

@Jpunt
Copy link

Jpunt commented Apr 6, 2016

The timeout-functionality seems to be broken:

require('promise-poller')({
  taskFn: () => {
    console.log('polling...');
    return Promise.reject();
  },
  interval: 10,
  timeout: 1000,
})
.then(() => console.log('success'))
.catch(() => console.log('failed'));

This will log "polling..." 5 times (which seems to be the default) and then fails. When adding retries: Infinity, it keeps polling infinitely.

Any idea what's up?

@joeattardi
Copy link
Owner

You're rejecting the promise immediately (return Promise.reject()$. So your task function runs and completes immediately.

The timeout comes into play for a task function that will take some time, like an Ajax request or something and if the promise returned by the task function doesn't resolve within 'timeout' milliseconds, it will reject.

Does that make sense?

@Jpunt
Copy link
Author

Jpunt commented Apr 7, 2016

Ah, that's something different than I thought it would be. I saw it as an alternative to retries, so it would try something over and over again, until a certain time was passed. Basically, x / interval as the amount of retries. Which is what I did in the meantime :) Thanks!

@Jpunt Jpunt closed this as completed Apr 7, 2016
@joeattardi
Copy link
Owner

Ok, great. Sorry for the confusion! I'll update the README to be a little clearer.

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

2 participants