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

feat: add optional delay for retry #335

Merged
merged 3 commits into from Mar 13, 2022

Conversation

antongolub
Copy link
Contributor

@antongolub antongolub commented Mar 13, 2022

Some cmds (like npm whoami) may hit the throttling limit, so a delay between call attempt might be very useful.

  • Tests pass
  • Appropriate changes to README are included in PR

@@ -23,7 +23,7 @@ export const echo: Echo
interface Retry {
(pieces: TemplateStringsArray, ...args: any[]): Promise<ProcessOutput>
}
export const retry: (count: number) => Retry
export const retry: <C extends number = 5, D extends number = 0>(count?: C, delay?: D) => Retry
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why extend 5?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const retry: (count: number = 5) => Retry

raises TS2371: A parameter initializer is only allowed in a function or constructor implementation.
So the only way to add a default arg value to fn type declaration is via generics (afair).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, reverted

@@ -23,7 +23,7 @@ export const echo: Echo
interface Retry {
(pieces: TemplateStringsArray, ...args: any[]): Promise<ProcessOutput>
}
export const retry: (count: number) => Retry
export const retry: (count?: number, delay?: number) => Retry
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better. Fixes an issue.

@antonmedv antonmedv merged commit 450917a into google:main Mar 13, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants