-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve .retry() method functionality with delays and prevent calling on successful request #1527
Conversation
I'm not understanding why the build is failing, can someone explain? I've spent half a day trying to get the tests to pass but cannot. So I need some help. The code does work as far as I've manually tested. |
@IAMtheIAM it seems that the tests fail due to unhandled promise rejection related to retry tests https://travis-ci.org/visionmedia/superagent/jobs/610131622?utm_medium=notification&utm_source=github_status if you fix + also fix merge conflicts (perhaps rebase to latest in our master branch and then add your work on top is best approach) - I would def merge and release this fix |
Closing until you submit a better PR |
Re-opened |
ping @3imed-jaberi |
…ow easily delaying retries by using a Promise and setTimeout.
…s only when there's a defined error.
- Make ESLint happy - Add babel plugin so aync/await works on node 6.x
@niftylettuce I resolved the merge conflicts by rebasing master onto my branch Update: The build failed with some lock file issue. Do you know what it means? |
Yes you forgot to update yarn lockfile and also you were missing adding |
One moment, I'm fixing |
@IAMtheIAM can you please pull the latest from master branch? I pushed commit 0c4f96f but the tests are still failing. Please resolve and let me know. |
@IAMtheIAM see https://travis-ci.org/github/visionmedia/superagent/jobs/709314173 for failing tests |
I have reverted 62eae78 until tests are passing and this PR is re-submitted. |
I'm going to leave the revert as is. This would be a major breaking change, as some may be using the |
With regards to the async/promise support, that would be nice to have, but it seems your PR broke all the tests. If you can fix this and then re-submit (taking out the |
This PR adds new functionality:
.retry()
as anasync
function. The purpose is to enableawait
ing a Promise within the callback. This could be to used to fetch some external data, or by simply utilizing a setTimeout to resolve the promise after a specified delay. The result is that the .retry() is delayed by the given amount (or after the data is received). It does not break existing functionality i.e. the.retry()
method can still be a normal synchronous function without any difference in behavior.This PR also Resolves #1526
.retry()
method from being invoked on a successful request, and only allows it to invoke when there is a specified non-null
error passed to.callback()