QVAC Logo

heartbeat( )

Checks if a delegated provider or the local SDK worker is responsive.

function heartbeat(params?: { delegate?: DelegateBase }): Promise<HeartbeatResponse>;

Sends a heartbeat round-trip to verify that a delegated provider is online or that the local SDK worker is responsive. When called without arguments, checks the local worker.

Parameters

NameTypeRequired?Description
paramsobjectOptional delegation target
params.delegateDelegateBaseThe provider to check — omit to check the local worker

DelegateBase

Consumers connect directly to the provider via the DHT using providerPublicKey — no topic or discovery step is required.

FieldTypeRequired?Description
providerPublicKeystringProvider peer public key hex string (from startQVACProvider)
timeoutnumberConnection timeout in milliseconds (min 100). On a cold DHT the first connect can take 15–45s.
healthCheckTimeoutnumberHealth check timeout in milliseconds (min 100)

Returns

Promise<HeartbeatResponse>

HeartbeatResponse

FieldTypeDescription
type"heartbeat"Response type discriminator
numbernumberRound-trip sequence number

Throws

ErrorWhen
INVALID_RESPONSE_TYPEResponse type does not match expected "heartbeat"

Examples

// Check if a delegated provider is online
try {
  await heartbeat({
    delegate: { providerPublicKey: "peerHex", timeout: 3000 },
  });
  console.log("Provider is online");
} catch {
  console.log("Provider is offline");
}

// Check if the local SDK worker is responsive
await heartbeat();

On this page