Skip to content

Commit aa01a7f

Browse files
committed
addressing feedback
1 parent 1de380c commit aa01a7f

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

  • packages/cli/src/commands/pg/upgrade

packages/cli/src/commands/pg/upgrade/wait.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,27 @@ export default class Wait extends Command {
1919
static topic = 'pg'
2020
static description = 'provides the status of an upgrade and blocks it until the operation is complete'
2121
static flags = {
22-
'wait-interval': flags.string({description: 'how frequently to poll in seconds (to avoid rate limiting)'}),
22+
'wait-interval': flags.integer({description: 'how frequently to poll in seconds (to avoid rate limiting)'}),
2323
'no-notify': flags.boolean({description: 'do not show OS notification'}),
2424
app: flags.app({required: true}),
2525
remote: flags.remote(),
2626
}
2727

28+
static examples = [
29+
heredoc(`
30+
# Wait for upgrade to complete with default settings
31+
$ heroku pg:upgrade:wait postgresql-curved-12345 --app myapp
32+
`),
33+
heredoc(`
34+
# Wait with custom polling interval
35+
$ heroku pg:upgrade:wait postgresql-curved-12345 --app myapp --wait-interval 10
36+
`),
37+
heredoc(`
38+
# Wait without showing OS notifications
39+
$ heroku pg:upgrade:wait postgresql-curved-12345 --app myapp --no-notify 10
40+
`),
41+
]
42+
2843
static args = {
2944
database: Args.string({description: `${nls('pg:database:arg:description')}`}),
3045
}
@@ -36,8 +51,7 @@ export default class Wait extends Command {
3651
const pgDebug = debug('pg')
3752

3853
const waitFor = async (db: AddOnAttachmentWithConfigVarsAndPlan | AddOnWithRelatedData) => {
39-
let interval = waitInterval && Number.parseInt(waitInterval, 10)
40-
if (!interval || interval < 0) interval = 5
54+
const interval = (!waitInterval || waitInterval < 0) ? 5 : waitInterval
4155
let status
4256
let waiting = false
4357
let retries = 20
@@ -50,9 +64,11 @@ export default class Wait extends Command {
5064
{hostname: pgHost()},
5165
))
5266
} catch (error) {
53-
const httpError = error as HTTPError
54-
pgDebug(httpError)
55-
if (!retries || httpError.statusCode !== 404) throw httpError
67+
if (error instanceof HTTPError && (!retries || error.statusCode !== 404)) {
68+
let httpError = error as HTTPError
69+
pgDebug(httpError)
70+
throw httpError
71+
}
5672
retries--
5773
status = {'waiting?': true, message: notFoundMessage}
5874
}

0 commit comments

Comments
 (0)