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

FieldTypeRequired?Description
topicstringHyperswarm topic hex string
providerPublicKeystringProvider peer public key hex string
timeoutnumberConnection timeout in milliseconds (min 100)
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: { topic: "topicHex", 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