Skip to content
Myr

Add retry example to `Tips` readme section (#386)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Dan Levy · committed by Sindre Sorhus · parent 2956ea1 · Browse files · 1 file+17 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>

Diff stats

1 file+17 added−0 removed

  • other:+17 added−0 removed

1 file+17 added−0 removed

modified:readme.md+17 added
530 unmodified lines
531List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.532533## Tips534535### Retry on error536537Gracefully handle failures by using automatic retries and exponential backoff with the [`p-retry`](https://github.com/sindresorhus/p-retry) package:538539```js540const pRetry = require('p-retry');541542const run = async () => {543 const results = await execa('curl', ['-sSL', 'https://sindresorhus.com/unicorn']);544 return results;545};546547(async () => {548 console.log(await pRetry(run, {retries: 5}));549})();550```551552### Save and pipe output from a child process553554Let's say you want to show the output of a child process in real-time while also saving it to a variable.555
63 unmodified lines