Skip to content

Releases: dfinity/agent-js

Release 2.1.3

23 Oct 17:04
6ef8afb
Compare
Choose a tag to compare

What's Changed

We have a couple fixes and some improvements to errors in this release.

Fixes

  • Fixed an issue where read_state polling requests would fail after the initial expiry, but before the request was processed
    • This was an edge case for subnets under high load. The read_state is allowed to use a fresh ingress_expiry, so pollForResponse and retry logic now uses this pattern
  • Added a check to handle a regression when calling the management canister using the new sync_call flow

Error handling

  • Fixed an issue where reject_code and reject_message weren't passed correctly to the error in synchronous call reject or trap responses.

  • new ActorCallError class

  • AgentError and ActorCallError support instanceof checks, as well as a name attribute that you can use for easier error handling

    • some old generic Errors are now labeled more preciesely
  • chore: Correct the typo in agent/src/actor.ts by @AlexV525 in #939

  • fix: trap and throw handling in v3 sync call by @krpeacock in #940

  • fix: read state with fresh expiry by @krpeacock in #938

  • test: automatically deploys trap canister if it doesn't exist yet dur… by @krpeacock in #942

  • chore: skip range check when the certificate comes from the management canister by @dfx-json in #945

  • feat: allow for setting HttpAgent ingress expiry using ingressExpiryInMinutes option by @krpeacock in #905

  • feat: improved assertion options for agent errors by @krpeacock in #908

New Contributors

Full Changelog: v2.1.2...v2.1.3

Release 2.1.2

30 Sep 00:15
a57d8a3
Compare
Choose a tag to compare

What's Changed

  • chore: revert "feat: allow option set agent replica time" by @dfx-json in #935

Full Changelog: v2.1.1...v2.1.2

Release 2.1.1

13 Sep 18:05
21cf470
Compare
Choose a tag to compare

What's Changed

Full Changelog: v2.1.0...v2.1.1

Release 2.1.0

12 Sep 18:20
cad8bde
Compare
Choose a tag to compare

Noteworthy Features

This feature includes the v3 synchronous call API! Calls to mainnet are able to bypass polling using the new endpoint

The HttpAgent allows you to set and read replicaTime, which it will maintain information about in order to handle disagreements between the client and replica about time.

Fixes and improvements for the useAuthClient library

Other changes and enhancements

New Contributors

Full Changelog: v2.0.0...v2.1.0

Release 2.0.0

16 Jul 17:30
ed4f2d0
Compare
Choose a tag to compare

Async HttpAgent and call response changes

Some small but backwards incompatible changes come with this release, but it enables some advanced use cases for libraries building with the HttpAgent.

Change 1 - HttpAgent constructor deprecation

The HttpAgent has a TSDoc warning against being constructed with the new constructor. We now prefer await HttpAgent.create(), which will automatically fetch the root key if you pass shouldFetchRootKey: true (for local development) to the HttpAgentOptions. HttpAgent.create will also automatically run the syncTime method, and configure the agent to calculate the difference between the system clock and the Internet Computer replica's time, which should reduce the occurrence of device sync issues. Since not all of your code may run inside of an async function, you can consider running a simple find and replace when upgrading to > v2.0.0.

The createSync method has identical behavior to new currently, and is preferred over accessing the constructor going forward.

function getActor(options){
-   return new HttpAgent(options);  
+   return HttpAgent.createSync(options);
}

Change 2 - Raw Call

In order to support ICRC-49, we need the HttpAgent to provide more details back after making a call. With this change, HttpAgent.call will provide:

requestId - the computed request ID to poll for
response - the raw `http` response from the boundary node
requestDetails - the details sent to the canister, used to compute the request ID

In addition, the output from pollForResponse needs to be updated as well. PollForResponse now returns

certificate: the Certificate tree sent along with the reply
reply: the certified response from the replica

Note

The v2 Actor is able to use older HttpAgent interfaces with backwards compatibility, but the pollForResponse type has a breaking return signature. You must use a v1 polling strategy with a v1 actor, and a v2 strategy with a v2 actor.

What's Changed

Full Changelog: v1.4.0...v2.0.0

Release 1.4.0

18 Jun 14:10
10a0950
Compare
Choose a tag to compare

What's Changed

  • chore: updates dfinity/conventional-pr-title-action to v3.2.0 by @krpeacock in #886
  • chore: updates dfinity/conventional-pr-title-action to v4.0.0 by @krpeacock in #889
  • chore: updates agent error response by @krpeacock in #885
  • fix: updated outdated urls in sample by @r-birkner in #888
  • fix: publish script will correctly update the package-lock.json file … by @krpeacock in #883
  • feat: add support for proof of absence in certificate lookups by @nathanosdev in #878
  • chore: update management canister interface with latest bitcoin features by @krpeacock in #890
  • fix: ObservableLog no longer extends Function by @krpeacock in #887
  • chore: bump braces by @tmu0 in #891
  • feat: strips out bitcoin query methods from management canister IDL by @krpeacock in #893

New Contributors

Full Changelog: v1.3.0...v1.4.0

Release 1.3.0

01 May 22:44
21e8d2b
Compare
Choose a tag to compare

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 strat: BackoffStrategy = {
  next: () => 1000
}

const agent = new HttpAgent({
  backoffStrategy: () => strat
});

Full Changelog: v1.2.1...v1.3.0

Release 1.2.1

25 Apr 17:14
f000c7d
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.2.0...v1.2.1

Release 1.2.0

25 Mar 20:44
d73d5e9
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.1.1...v1.2.0

Release 1.1.1

19 Mar 16:03
4ba3407
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.1.0...v1.1.1