We’re happy to announce v5.2.0 of @icp-sdk/core, which brings improved error readability, a fix for a common bundler issue, and pluggable caching for subnet node keys.
What’s New
Pluggable ExpirableStore for Subnet Node Key Caching (#1280)
HttpAgent now accepts a subnetNodeKeyExpirableStore option, allowing cached subnet node keys to be shared across multiple agent instances and page reloads. In browsers, an IndexedDB-backed store is used by default, eliminating redundant key fetches for dApps that create multiple agents.
Hex-Encoded Error Messages and Error Verbosity (#1312)
Uint8Array fields in error messages (e.g. arg, certificate, nonce) are now hex-encoded instead of being serialized byte-by-byte with JSON.stringify. This prevents multi-thousand-line error output that could freeze log viewers.
A new ErrorVerbosity setting lets you control the level of detail:
Normal (default): omits large binary fields with a hint to enable verbose mode
Verbose: includes full hex-encoded values
import { ErrorCode, ErrorVerbosity } from "@icp-sdk/core/agent";
ErrorCode.verbosity = ErrorVerbosity.Verbose;
Bug Fixes
Bind globalThis.fetch to Prevent “Illegal Invocation” (#1316)
Users of bundlers like Vite and webpack no longer need to manually pass fetch: window.fetch.bind(window) when creating an HttpAgent. The SDK now binds the default fetch to globalThis automatically, preventing the “Illegal invocation” error that occurred when bundlers stripped the this context.