What’s Changed
New feature - exponential backoff for retries, using a new HttpAgent option - backoffStrategy
. The agent can accept a BackoffStrategyFactory
, which is a function that returns a BackoffStrategy
. The strategy itself must include a next
method, which yields a number
or null
The default strategy mimics the one used by agent-rs
. It will increase the interval using exponential backoff, and adding in a “jitter”, randomizing the result a little to decrease the likelihood of calls firing at the same time as your application scales, which could cause performance issues under certain conditions.
If you prefer a constant backoff, a custom factory would look something like this in TypeScript:
import { HttpAgent, BackoffStrategy } from '@dfinity/agent';
const strategy: BackoffStrategy = {
next: () => 1000
}
const agent = new HttpAgent({
backoffStrategy: () => strategy
});
- chore: adds required
npm audit
check to PRs by @krpeacock in chore: adds required `npm audit` check to PRs by krpeacock · Pull Request #880 · dfinity/agent-js · GitHub - feat: retry delay strategy by @krpeacock in feat: retry delay strategy by krpeacock · Pull Request #871 · dfinity/agent-js · GitHub
- docs: adds instructions on how to run unit and e2e tests to the README by @krpeacock in docs: adds instructions on how to run unit and e2e tests to the README by krpeacock · Pull Request #881 · dfinity/agent-js · GitHub
Full Changelog: Comparing v1.2.1...v1.3.0 · dfinity/agent-js · GitHub