{"action":"created","issue":{"url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1505","repository_url":"https://api.github.com/repos/aws/aws-sdk-js","labels_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1505/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1505/comments","events_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1505/events","html_url":"https://github.com/aws/aws-sdk-js/issues/1505","id":227518629,"number":1505,"title":"waitFor should have an initial timeout option","user":{"login":"antonsamper","id":102233,"avatar_url":"https://avatars0.githubusercontent.com/u/102233?v=3","gravatar_id":"","url":"https://api.github.com/users/antonsamper","html_url":"https://github.com/antonsamper","followers_url":"https://api.github.com/users/antonsamper/followers","following_url":"https://api.github.com/users/antonsamper/following{/other_user}","gists_url":"https://api.github.com/users/antonsamper/gists{/gist_id}","starred_url":"https://api.github.com/users/antonsamper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antonsamper/subscriptions","organizations_url":"https://api.github.com/users/antonsamper/orgs","repos_url":"https://api.github.com/users/antonsamper/repos","events_url":"https://api.github.com/users/antonsamper/events{/privacy}","received_events_url":"https://api.github.com/users/antonsamper/received_events","type":"User","site_admin":false},"labels":[{"id":25617906,"url":"https://api.github.com/repos/aws/aws-sdk-js/labels/Feature%20Request","name":"Feature Request","color":"d7e102","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-09T22:39:32Z","updated_at":"2017-05-10T20:49:25Z","closed_at":null,"body":"I've been playing around with RDS instances and modifying them but i have noticed an issue that may affect others. What I'm trying to do is upgrade one of my RDS instances and once the upgrade is complete, then continue with the rest of the code:\r\n\r\n```javascript\r\nreturn RDS.modifyDBInstance({\r\n    DBInstanceIdentifier: instanceId,\r\n    DBInstanceClass: instanceClass,\r\n    ApplyImmediately: true\r\n}).promise().then(() => {\r\n    return RDS.waitFor('dBInstanceAvailable', {\r\n        DBInstanceIdentifier: instanceId\r\n    }).promise();\r\n});\r\n```\r\n\r\nThe problem that I'm having with the above is that the `RDS.waitFor` promise is resolved straight away because the `ApplyImmediately` settings seem to take a few seconds to actually start. As a result, to make the code work as expected, I'm having to manually delay the call to `waitFor` (with bluebirds `.delay`)\r\n\r\n```javascript\r\nreturn RDS.modifyDBInstance({\r\n    DBInstanceIdentifier: instanceId,\r\n    DBInstanceClass: instanceClass,\r\n    ApplyImmediately: true\r\n}).promise().then(() => {\r\n    return Promise.delay(5000).then(() => {\r\n        return RDS.waitFor('dBInstanceAvailable', {\r\n            DBInstanceIdentifier: instanceId\r\n        }).promise();\r\n    });\r\n});\r\n```\r\n\r\nCurrently, the `waitFor` function seems to run straight away and then every 30 seconds. Could we have an option to wait 30 seconds before the first check?"},"comment":{"url":"https://api.github.com/repos/aws/aws-sdk-js/issues/comments/300608093","html_url":"https://github.com/aws/aws-sdk-js/issues/1505#issuecomment-300608093","issue_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1505","id":300608093,"user":{"login":"jeskew","id":705500,"avatar_url":"https://avatars2.githubusercontent.com/u/705500?v=3","gravatar_id":"","url":"https://api.github.com/users/jeskew","html_url":"https://github.com/jeskew","followers_url":"https://api.github.com/users/jeskew/followers","following_url":"https://api.github.com/users/jeskew/following{/other_user}","gists_url":"https://api.github.com/users/jeskew/gists{/gist_id}","starred_url":"https://api.github.com/users/jeskew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeskew/subscriptions","organizations_url":"https://api.github.com/users/jeskew/orgs","repos_url":"https://api.github.com/users/jeskew/repos","events_url":"https://api.github.com/users/jeskew/events{/privacy}","received_events_url":"https://api.github.com/users/jeskew/received_events","type":"User","site_admin":false},"created_at":"2017-05-10T20:49:25Z","updated_at":"2017-05-10T20:49:25Z","body":"Hi @antonsamper,\r\n\r\nI can definitely see how the delay between when the `modifyDBInstance` promise is resolved and when the instances begin reporting their status as `modifying` can be frustrating, but I don't think adding an initial delay to waiters will solve it in all cases. If RDS requires a few retries to contact the node or there's some transient networking issue that keeps the modify command from reaching the affected instance, then the instance might still report as `available` even after 5 or 30 seconds.\r\n\r\nA more reliable solution would be to add a `DBInstanceModifying` waiter that uses the same delay and maxAttempts count as `DBInstanceAvailable` but that uses `modifying` as its target instance status instead of `available`. You could then wait for the modifications to take effect by chaining the waiters together:\r\n\r\n```javascript\r\nreturn RDS.modifyDBInstance({\r\n    DBInstanceIdentifier: instanceId,\r\n    DBInstanceClass: instanceClass,\r\n    ApplyImmediately: true\r\n}).promise().then(() => {\r\n    return RDS.waitFor('dBInstanceModifying', {\r\n        DBInstanceIdentifier: instanceId\r\n    }).promise();\r\n}).then(() => {\r\n    return RDS.waitFor('dBInstanceAvailable', {\r\n        DBInstanceIdentifier: instanceId\r\n    }).promise();\r\n}).then(() => {\r\n    // the modifications have been applied\r\n});\r\n```\r\n\r\nWould that be a reasonable remedy?"}}
{"actor":{"display_login":"jeskew"}}