Skip to content

invokeHookSafely

invokeHookSafely<TEvent>(hook, event): void

Defined in: src/observability/hooks.ts:219

Invokes a single optional hook and swallows both synchronous throws and rejected Promises. Use this at every site where the kawasekit core surfaces call user-provided callbacks — it is the contract that guarantees hooks cannot destabilise verify / settle / fetch flows.

If a hook misbehaves, the error is discarded silently — kawasekit’s observability promise is “best-effort, never blocking”. Future work (planned in plan D12) may route discarded errors to a structured logger so operators can see hook bugs without paying for them in hot paths.

Type Parameters

TEvent

TEvent

Parameters

hook

HookCallback<TEvent> | undefined

event

TEvent

Returns

void

Example

import { invokeHookSafely } from "kawasekit/observability";
invokeHookSafely(hooks.onSettle, {
kind: "settle",
result: "success",
startedAtMs,
durationMs: Date.now() - startedAtMs,
network: "eip155:80002",
payer,
amount,
transaction: txHash,
});